PHP SQLite3捕获所有错误



我正在尝试捕捉PHP中所有SQLite3错误的方法?我试过很多次,似乎都奏效了。考虑下面的代码,它是否足以捕获所有错误?有人能提出其他建议吗?

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

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

相关内容

最新更新