在CodeIgniter,SQL中的布尔值上调用成员函数result() [英] Call to a member function result() on boolean in CodeIgniter, SQL
问题描述
我正在尝试根据搜索关键字查看$ data [结果中包含的数据,但是每次都遇到上述致命错误,有人可以为我提供帮助。
我的控制器
I'm trying to see what data is coming in $data['results'] on basis of search keyword but getting above mentioned fatal error every time, can somebody help me with it. My Controller
public function execute_search()
{
$search_term = $this->input->post('search');
$data['results'] = $this->UserModel->get_results($search_term);
print_r($results); die;
//$this->load->view('search_result',$data);
}
我的模型:
public function get_results($search_term)
{
//var_dump($search_term);die;
$this->db->select('*');
$this->db->from('Competitor_Products');
$this->db->where('CProduct_Article_Number', $search_term);
return $this->db->get()->result();
}
推荐答案
我遇到了同样的问题,我的应用程序运行良好,直到2天前我开始遇到相同的错误。弄清楚查询根本不返回任何数据,并得到了您提到的相同错误。不知何故,我找到了一个对我有用的解决方案。我必须编辑我在CI中使用的mysqli驱动程序。
I faced the same issue, my application was working fine until 2 days ago i started getting the same error. figured out the query was returning no data at all and got the same error you mentioned. Somehow i found a solution which worked for me. I had to edit the mysqli driver i was using in CI.
在第147行/public_html/system/database/drivers/mysqli/mysqli_driver.php
我更改了以下代码
At Line num 147 /public_html/system/database/drivers/mysqli/mysqli_driver.php I changed the below code
`$this->_mysqli->options(MYSQLI_INIT_COMMAND,
'SET SESSION sql_mode =
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
@@sql_mode,
"STRICT_ALL_TABLES,", ""),
",STRICT_ALL_TABLES", ""),
"STRICT_ALL_TABLES", ""),
"STRICT_TRANS_TABLES,", ""),
",STRICT_TRANS_TABLES", ""),
"STRICT_TRANS_TABLES", "")'
);`
对此代码
`$this->_mysqli->options(MYSQLI_INIT_COMMAND,
'SET SESSION sql_mode =
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
@@sql_mode,
"ONLY_FULL_GROUP_BY,", ""),
",ONLY_FULL_GROUP_BY", ""),
"ONLY_FULL_GROUP_BY", ""),
"ONLY_FULL_GROUP_BY,", ""),
",ONLY_FULL_GROUP_BY", ""),
"ONLY_FULL_GROUP_BY", "")'
);`
并确保将限制
设置为 FALSE
在/ application / config /文件夹下的database.php文件中。像这样的'stricton'=>否,
And make sure the striction
is set to FALSE
in your database.php file under /application/config/ folder. Like this 'stricton' => FALSE,
这篇关于在CodeIgniter,SQL中的布尔值上调用成员函数result()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!