2017-04-24 55 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();

柜面如果其是用于查询没有价值的,它将返回一个空数组。所以现在你的条件会起作用。

相关问题