[eluser]trumpetnl[/eluser]
Think OO :-) !
The OBJECT you create by retrieving data from the database has METHODES. One of these methodes is the
result_array() methode, another one is the
row() methode.
If you want to perform tasks on an array of result (the result of using the methode
result_array()) you can use your foreach loop (you have (likely more then one result and want to cycle thru the array, hence you LOOP).
Code:
foreach ($q->result_array() as $row)
{
$data[] = $row;
}
When you only want to work with the first row of the result you can use
So, in your case, drop the foreach loop altogether and put in
Code:
$data = $q->row();
return $data;
Granted, this object/array thingy can be confusing, just remember, when using the database library, your result is an OBJECT with properties and methodes. Think OO and all will fall into place (at least for me it did
hope this helps