|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81376 fetchArray refuses to work with UPDATE ... RETURNING
Submitted: 2021-08-21 19:39 UTC Modified: 2021-08-25 14:18 UTC
From: abrahin dot andrei at yandex dot ru Assigned:
Status: Verified Package: SQLite related
PHP Version: 8.0.9 OS: Arch Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: abrahin dot andrei at yandex dot ru
New email:
PHP Version: OS:


 [2021-08-21 19:39 UTC] abrahin dot andrei at yandex dot ru
From manual page:

SQLite3Result::fetchArray() returns FALSE on 'UPDATE ... RETURNING ...' even if some rows were affected.

Please note that this interface is fully supported since v3.35, and i have v3.36 installed (as evidenced by output of `SQLite3::version()`).

Test script:
$GLOBALS['db'] = new SQLite3('testdb.sqlite');

$db->exec('CREATE TABLE IF NOT EXISTS cron (time INTEGER, type INTEGER, private TEXT');
$db->exec('INSERT INTO cron (time, type, private) VALUES (3, 1, 0)');

$stmt = $db->prepare('UPDATE cron SET time = 10 WHERE time < 10 RETURNING *;');
$res = $stmt->execute();

var_dump($res->fetchArray()); # <-- returns false, should instead return a row

Expected result:
I expected to see a row full of data and enjoy the possibilities provided by the SQLite v3.36.0

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-23 12:23 UTC]
-Status: Open +Status: Verified -Type: Documentation Problem +Type: Bug
 [2021-08-23 12:23 UTC]
I can confirm the issue.  It has the same root cause as bug
#64531, namely that SQLite3::execute() already calls
sqlite3_step() to learn if there is a result set or not, and then
resets the statement to be able to start from the beginning.  This
doesn't work for DML statements, though.

I think the only way forward to fix this issue and some others,
would be to drop SQLite3Result altogether, and to move its methods
to SQLite3Statement.  Serious BC break, though.
 [2021-08-23 12:25 UTC]
> I expected to see a row full of data and enjoy the possibilities
> provided by the SQLite v3.36.0

Use PDO_SQLite instead. :)
 [2021-08-25 09:05 UTC]
@cmb PDO uses a flag to skip the next step without resetting, maybe we should do that in sqlite3 as well?
 [2021-08-25 14:18 UTC]
@nikic, see <>.
TL;DR: we *need* to drop SQLite3Result altogether.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Nov 30 21:09:15 2022 UTC