微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – 检查codeigniter查询错误,而不是向用户显示它们

如何检查查询是否出错而不是向用户显示错误(包含不安全的数据库信息).

假设我有这样的情况,我的分页类采用URI段来显示页面
example.com/page/uri_segment.如果有人像这样写这个example.com/page/bla_bla_bla,我会收到一个错误,显示有关我的数据库的信息.

我怎么处理这个?

在application / config / database.PHP中设置
// suppress error output to the screen
$db['default']['db_debug'] = FALSE;

在您的模型或控制器中:

// 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();
}

原文地址:https://www.jb51.cc/php/138542.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐