I’m using SQLite3, and the SQLite3 class that’s built into PHP. The following code does not work in the way I would expect based on other mysql classes that I’m familiar with. The manual says that the exec method should return true if the query succeeded, false on failure. However, from what I can see, that doesn’t seem to be the case with this.
$udb = new SQLite3('app.sqlite');
if($udb->exec("DELETE FROM users WHERE id = $del") != FALSE)
$message = 'Deleted User';
else
$message = 'Could not delete the user.';
I would expect that if the row with that ID did not exist, the query would return false or 0 or ‘0’. None of these are accurate. In fact, I can’t figure out what the function is returning at all.
Could someone help out with what this error checking if block should look like?
$udb->changes() > 0is what you are looking forhttp://php.net/manual/en/sqlite3.changes.php