简体   繁体   中英

PHP SQLite3 Catch All Errors

I am trying ways to catch all SQLite3 errors in PHP? 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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