#46007 [Fbk->Opn]: PDO_Sqlite: PDOStatement::rowCount() and PDO::exec() always returns 0
| From: | aragon at phat dot za dot net | Date: | Tue, 04 Nov 2008 20:27:07 +0000 |
| Subject: | #46007 [Fbk->Opn]: PDO_Sqlite: PDOStatement::rowCount() and PDO::exec() always returns 0 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-130609@lists.php.net to get a copy of this message | ||
ID: 46007
User updated by: aragon at phat dot za dot net
Reported By: aragon at phat dot za dot net
-Status: Feedback
+Status: Open
Bug Type: PDO related
Operating System: FreeBSD 7.0-STABLE
PHP Version: 5.2.6
New Comment:
Just tried the latest snapshot. It appears to be fixed. Thanks a
million!
Previous Comments:
------------------------------------------------------------------------
[2008-10-28 22:09:53] jani@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
------------------------------------------------------------------------
[2008-09-06 05:45:07] aragon at phat dot za dot net
Description:
------------
When executing an UPDATE query to a SQLite3 database,
PDOStatement::rowCount() and PDO:exec() returns 0 instead of 1 or more
when rows are updated in the database.
Reproduce code:
---------------
$db = new PDO('sqlite:crnl.db');
// PDO::exec() example
$sql = 'SELECT tags FROM blog_entries WHERE docid = 1';
$statement = $db->query($sql);
$row = $statement->fetch();
echo $row[0], "\n";
$sql = 'UPDATE blog_entries SET tags = \'test\' WHERE docid = 1';
echo $db->exec($sql), "\n";
$sql = 'SELECT tags FROM blog_entries WHERE docid = 1';
$statement = $db->query($sql);
$row = $statement->fetch();
echo $row[0], "\n";
// PDO:rowCount() example
$sql = 'UPDATE blog_entries SET tags = \'untest\' WHERE docid = 1';
echo $db->query($sql)->rowCount(), "\n";
$sql = 'SELECT tags FROM blog_entries WHERE docid = 1';
$statement = $db->query($sql);
$row = $statement->fetch();
echo $row[0], "\n";
Expected result:
----------------
untest
1
test
1
untest
Actual result:
--------------
untest
0
test
0
untest
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46007&edit=1