Php 对在codeingiter中运行select query的非对象调用成员函数result()
我试图从数据库中获取一些值,我尝试了如下代码Php 对在codeingiter中运行select query的非对象调用成员函数result(),php,codeigniter,Php,Codeigniter,我试图从数据库中获取一些值,我尝试了如下代码 $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'
$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");
}
但它显示了一些错误,如对非对象调用成员函数result(),而不是使用
$data=$query->result()代码>使用$data=$query->result_array()代码>
如果它们对于查询没有值,它将返回一个空数组。因此,现在您的if-else条件将起作用。的可能副本