There are functions to return your data as an object:
$query = $this->db->query("YOUR QUERY"); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { echo $row->title; echo $row->name; echo $row->body; } }
Or an array:
$query = $this->db->query("YOUR QUERY"); foreach ($query->result_array() as $row) { echo $row['title']; echo $row['name']; echo $row['body']; }
I always returned my data as arrays, but when does it happen that returning an βobjectβ is preferable?
Don p source share