I think I have a problem with codeigniter (version 3.1.2) active record...
My model function is:
function select_country($ID, $typec)
{
$data = '';
$this ->db -> select ('*');
$this ->db -> where ('ID', $ID);
$query = $this ->db -> get ('country');
if ($query->num_rows()>0){
foreach ($query->result() as $row){
$data=$row->$typec;
}
}
return $data;
}
When I run it I get this error:
A Database Error Occurred
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM country WHERE ID = '6'' at line 1
SELECT `ads`, * FROM `country` WHERE `ID` = '6'
Filename: models/Country_model.php
Line Number: 40
I noticed an additional line : "SELECT ads, * FROM country WHERE ID = '6'" but I don't know from where is it. There is no 'ads' column.
If I use "$query = $this ->db -> query ('SELECT * FROM country WHERE ID = '.$ID); " there is no error.
What could be the problem?