1

我正在尝试获得类似的结果select * from bookdetails where display_id = $id with few foreign key join condition

我已经编写了以下查询,但它显示的错误如下:

致命错误:在 C:\xampp\htdocs\project 中第 432 行的非对象上调用成员函数 num_rows(),即 *if ($query->num_rows() > 0)...

模型.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;
}
4

1 回答 1

2

您在get()函数中缺少表名:

 $query = $this->db->get('bookdetails'); 

get_where()或者您可以简单地用开头的语句替换它:

$query = $this->db->get_where('bookdetails',array('display_id'=>$id)); 
于 2013-02-03T08:27:38.610 回答