Dec 23, 2013 - Calling ->result(), you have the result of the query execution in an array. You might callyour variable like this, for example : $cours = $this->db->from('cour') ->where('id_element',(int) $id_element[0]->id) ->limit($limit, $start) ->get() ->result();. Then change your test as : if (count($cours) > 0) { foreach ...