I'm using CodeIgniter, and I want to get some data from a table in a database.
in my Model, I have this function :
public function fetch_cours($limit, $start, $element) {
$id_element = $this->db->from('element')
->where('name',$element)
->limit(1)
->get()
->result();
$query = $this->db->from('cour')
->where('id_element',(int) $id_element[0]->id)
->limit($limit, $start)
->get()
->result();
var_dump($query);
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;
}
I want this function to return some records in the cour
table.
In my controller I have this line :
$cours = $this->cours_m->fetch_cours(10,0,'Programmation Orientée Objet (Java)');
When I call my controller I get this message :
The line 38 is : if ($query->num_rows() > 0) {
So I did a var_dump($query) and this is the output :
What's the problem ? and how can I solve it ?