How can I determine the number of rows affected in a SQLite 2 query in PHP

I am writing an application in PHP 5. I want to delete some lines in the SQLite v2 database file. I am doing something like this:

$sqliteConnection = new SQLiteDatabase('path/to/db');
$queryString = "DELETE FROM myTable WHERE status='not good'";
$result = $sqliteConnection->query($queryString);

how to find out how many rows affected this query? how many lines did i delete?

+3
source share
2 answers

The PHP function sqlite_changes()does this for you.

Returns the number of rows that were changed by the last SQL statement executed using the database descriptor dbhandle.

Call it either in a procedural style:

echo 'Number of rows modified: ', sqlite_changes($sqliteConnection);

or in the style of the object:

echo 'Number of rows modified: ', $sqliteConnection->changes();
+7
source
0

All Articles