I'm writing an application in PHP 5. I want to delete some rows in a SQLite v2 database file. I'm doing something like this:
我正在用PHP 5编写一个应用程序。我想删除SQLite v2数据库文件中的一些行。我正在做这样的事情:
$sqliteConnection = new SQLiteDatabase('path/to/db');
$queryString = "DELETE FROM myTable WHERE status='not good'";
$result = $sqliteConnection->query($queryString);
how can I know how many rows were affected by this query? how many rows have I deleted?
如何知道这个查询影响了多少行?我删除了多少行?
2 个解决方案
#1
7
The PHP function sqlite_changes()
does this for you.
PHP函数sqlite_changes()为您实现了这一点。
Returns the numbers of rows that were changed by the most recent SQL statement executed against the
dbhandle
database handle.返回最近针对dbhandle数据库句柄执行的SQL语句所更改的行数。
Call it either in procedural-style:
以程序的方式称呼它:
echo 'Number of rows modified: ', sqlite_changes($sqliteConnection);
or in object-style:
或在对象样式:
echo 'Number of rows modified: ', $sqliteConnection->changes();
#2
#1
7
The PHP function sqlite_changes()
does this for you.
PHP函数sqlite_changes()为您实现了这一点。
Returns the numbers of rows that were changed by the most recent SQL statement executed against the
dbhandle
database handle.返回最近针对dbhandle数据库句柄执行的SQL语句所更改的行数。
Call it either in procedural-style:
以程序的方式称呼它:
echo 'Number of rows modified: ', sqlite_changes($sqliteConnection);
or in object-style:
或在对象样式:
echo 'Number of rows modified: ', $sqliteConnection->changes();