bar*_*anq 11 php mysql codeigniter
如何检查查询是否出错而不是向用户显示错误(包含不安全的数据库信息).
假设我有这样的情况,我的分页类采用URI段来显示页面
example.com/page/uri_segment.如果有人这样写,example.com/page/bla_bla_bla我会收到一个错误,显示有关我的数据库的信息.
我怎么处理这个?
cwa*_*ole 29
在application/config/database.php中设置
// suppress error output to the screen
$db['default']['db_debug'] = FALSE;
Run Code Online (Sandbox Code Playgroud)
在您的模型或控制器中:
// try the select.
$dbRet = $this->db->select($table, $dataArray);
// select has had some problem.
if( !$dbRet )
{
$errNo = $this->db->_error_number();
$errMess = $this->db->_error_message();
// Do something with the error message or just show_404();
}
Run Code Online (Sandbox Code Playgroud)