Doc->Bug #81376 [Opn->Ver]: fetchArray refuses to work with UPDATE ... RETURNING

From: Date: Mon, 23 Aug 2021 12:23:01 +0000
Subject: Doc->Bug #81376 [Opn->Ver]: fetchArray refuses to work with UPDATE ... RETURNING
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236016@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81376&edit=1 ID: 81376 Updated by: cmb@php.net Reported by: abrahin dot andrei at yandex dot ru Summary: fetchArray refuses to work with UPDATE ... RETURNING -Status: Open +Status: Verified -Type: Documentation Problem +Type: Bug Package: SQLite related Operating System: Arch Linux PHP Version: 8.0.9 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2021-08-21 19:39:40] abrahin dot andrei at yandex dot ru Description: ------------ --- From manual page: https://php.net/sqlite3result.fetcharray --- 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()). https://www.sqlite.org/lang_returning.html https://www.sqlite.org/lang_update.html 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: -------------- bool(false) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81376&edit=1

« previous php.bugs (#236016) next »