我想获得像select * from bookdetails where display_id = $id with few foreign key join condition
我编写了以下查询,但它显示的错误如下:
致命错误:在第4行的C:\ xampp \ htdocs \ project中调用非对象的成员函数num_rows(),即* 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;
}
答案 0 :(得分:2)
get()
函数中缺少表名:
$query = $this->db->get('bookdetails');
或者您只需将其替换为开头的get_where()
语句:
$query = $this->db->get_where('bookdetails',array('display_id'=>$id));