当前位置:首页 > 数据库 > SQlite

如何在PHP中确定SQLite 2查询中受影响的行数

我正在用PHP 5编写一个应用程序.我想删除SQLite v2数据库文件中的一些行.我正在做这样的事情:

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

我怎么知道这个查询影响了多少行?我删除了多少行?

解决方法:

PHP函数sqlite_changes()为您完成此操作.

Returns the numbers of rows that were changed by the most recent SQL statement executed against the dbhandle database handle.

以程序方式调用它:

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

或者是对象式的:

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

【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!