用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3965|回复: 1
收起左侧

请教CI如何捕获SQL语句异常

[复制链接]
发表于 2013-3-5 11:11:51 | 显示全部楼层 |阅读模式
$this->db->where($conArray);
$dataList=$this->db->get($this->_table)->result_array();

conArray是条件数组,当里面的字段都正常的时候,可以正确执行,但是当字段异常  比如原本的 id=>1 改成idtest=>1就报错了
提示Unknown column 'idtest' in 'where clause'

那么在CI中,如何处理这种类似的SQL错误呢?

小弟尝试用过CI提供的事务方法
$this->db->trans_start();
........
$this->db->trans_complete();
if ($this->db->trans_status() === FALSE)
{
.........................
}
但还是捕获不到异常,直接就报错了

现向各位大神求救,如何处理,望不吝赐教  小弟感激不尽啊!~
发表于 2013-3-5 18:32:03 | 显示全部楼层

  1.                         $error_msg = $this->db->_error_message();
复制代码

本版积分规则