1
我試圖得到像select * from bookdetails where display_id = $id with few foreign key join condition
無法使用從哪裏得到的結果和笨
我寫了下面的查詢結果加入條件,但它顯示類似的錯誤:
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)...
模型。 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;
}
新的疑問:我想情況下,我上面的查詢添加一個順序。即:'orderby auth_lastname'。這個怎麼做? –
只需將上面的'get'行(或上面的連接):'$ this-> db-> order_by('auth_lastname','ASC');' – Shomz
感謝您的幫助。 –