2017-04-24 27 views
-2

我試圖採取一些價值觀形成的數據庫運行選擇查詢,我試圖這樣調用一個成員函數結果()一個非對象在哪裏codeingiter

$condition = ['restaurant_id' => $restaurant_id, 'menu_category_id' => $menu_category_id, 'current_template_id' => '0']; 
    $this->db->select('time_range'); 
    $this->db->from('menu_category_timing_t'); 
    $this->db->where($condition); 
    $query = $this->db->get(); 
    $data = $query->result(); 

    if ($data) { 
     print_r("data available") 
    } 
    else { 
     print_r("data is not available"); 
    } 

但它顯示的代碼一些誤差呼叫一個成員函數的結果()非對象

+1

可能重複[參考 - 這是什麼錯誤在PHP中意味着什麼?](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) –

+0

可能的重複[調用成員函數結果()非對象codeigniter](http://stackoverflow.com/questions/22685990/call-to-member-function-result-of-non-object-codeigniter) –

回答

0

代替使用$data = $query->result();使用$data = $query->result_array();

櫃面如果其是用於查詢沒有價值的,它將返回一個空數組。所以現在你的條件會起作用。

相關問題