PHP SQLite3捕获所有错误

时间:2011-06-30 18:17:37

标签: php sqlite catch-all

我正在尝试捕获PHP中的所有SQLite3错误?我尝试了很多,他们似乎都工作。考虑下面的代码,是否足以捕获所有错误?有人可以提出别的建议吗?

$result = $stmt->execute();
if ($this->db->lastErrorCode()){
    throw new DatabaseError($this->db->lastErrorMsg(), 
                            $this->db->lastErrorCode());
} else {
    return $this->db->changes();
}

1 个答案:

答案 0 :(得分:0)

我认为这实际上已经足够了,因为当出现错误时会出现错误代码,所以这必须起作用。