Reputation: 2174
i am trying to get the results like select * from bookdetails where display_id = $id with few foreign key join condition
I have written the following query but it is showing error like:
Fatal error: Call to a member function num_rows() on a non-object in C:\xampp\htdocs\project at line432` i.e *if ($query->num_rows() > 0)...
Model.php
public function get_all_book_list_atHomeTop($id, $limit, $start)
{
$this->load->database();
$this->db->limit($limit, $start);
$this->db->get_where('bookdetails', array('display_id' => $id));
//-------join condition ------------------
//------------Ends here Join condition
$query = $this->db->get();
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
$data[] = $row;
}
return $data;
}
return false;
}
Upvotes: 1
Views: 81
Reputation: 3192
You are missing table name in get()
function:
$query = $this->db->get('bookdetails');
Or you can simply replace it with get_where()
statement you have at the beginning:
$query = $this->db->get_where('bookdetails',array('display_id'=>$id));
Upvotes: 2