简体   繁体   English

PHP SQLite3 捕获所有错误

[英]PHP SQLite3 Catch All Errors

I am trying ways to catch all SQLite3 errors in PHP?我正在尝试捕获 PHP 中的所有 SQLite3 错误的方法? I have tried many and they all seem to work.我已经尝试了很多,它们似乎都有效。 Consider the code below, is it enough to catch all errors?考虑下面的代码,是否足以捕获所有错误? Can someone suggest anything else?有人可以提出其他建议吗?

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

I think this is actually enough because there's an error code when an error is raised of course so this must work.我认为这实际上就足够了,因为当出现错误时当然会出现错误代码,所以这必须有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM