|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33841 PDO_SQLITE: $stmt->rowCount() always returns 0 on INSERT, UPDATE and DELETE
Submitted: 2005-07-23 23:23 UTC Modified: 2005-07-24 01:32 UTC
From: people05 at sopic dot com Assigned:
Status: Closed Package: PDO related
PHP Version: 5.1.0b3 OS: Debian GNU/Linux 3.1
Private report: No CVE-ID:
 [2005-07-23 23:23 UTC] people05 at sopic dot com
I'm not sure if it's a error in the docs or a PDO bug. http:// says, 
"PDOStatement::rowCount() returns the number of rows affected 
by the last DELETE, INSERT, or UPDATE statement executed by 
the corresponding PDOStatement object." When I execute my code 
sample, $stmt->rowCount() always returns int(0) instead of the 
expected int(1).

Some lines down the page, the docs say that rowCount() doesn't 
work on a SELECT with the most databases, but there's no 
exception for INSERT, UPDATE or DELETE.

Reproduce code:

try {
	$db = new PDO("sqlite:/tmp/sqlite.sdb");
	$stmt = $db->prepare("INSERT INTO test ( name ) VALUES ( :name ) ");
	$stmt->bindParam(':name', $name);
	$name = 'Andreas';
	$last_insert_id = $db->lastInsertId();
	$stmt = $db->prepare("UPDATE test SET name = :name ");
	$stmt->bindParam(':name', $name);
	$name = 'Peter';
	$stmt = $db->prepare("DELETE FROM test");
} catch (Exception $e) {
	echo $e->getMessage();	


Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-23 23:38 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

The number of rows affected by those operations will be provided to you by the exec() method as the returned value.
 [2005-07-24 01:32 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Fri Nov 27 13:01:31 2015 UTC