Simple problem I'm stuck on:
Here is my active record query:
public function get_org()
{
return $this->db
->get('organizations')
->row();
}
This only returns the first row in the DB.
If I get rid of ->row();
it returns this odd bit:
object(CI_DB_mysql_result)#17 (8) {
["conn_id"]=>
resource(8) of type (mysql link persistent)
["result_id"]=>
resource(12) of type (mysql result)
["result_array"]=>
array(0) {
}
["result_object"]=>
array(0) {
}
["custom_result_object"]=>
array(0) {
}
["current_row"]=>
int(0)
["num_rows"]=>
int(2)
["row_data"]=>
NULL
}
What's odd is that the exact same query works perfectly elsewhere in my code for different tables.
Suggestions?
Try like
public function get_org()
{
$query = $this->db->get('organizations');
foreach ($query->result() as $row)
{
$result_arr[] = $row;
}
return $result_arr;
}
row()
will return only one row of the result array.
Or you can also try with result_array()
as @Hashem Qolami said like
public function get_org()
{
$result = $this->db->get('organizations');
return $result->result_array();
}