|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-12-02 15:54 UTC] nikic@php.net
-Status: Open
+Status: Duplicate
[2020-12-02 15:54 UTC] nikic@php.net
[2020-12-02 16:03 UTC] dougnelson at silktide dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 04:00:01 2025 UTC |
Description: ------------ A caveat that the code being here isn't ideal, but this has caused a BC and some unexpected prod problems. If you run a delete query using PDO-MySQL in the format: $statement->prepare($query) $statement->execute() $statement->fetchAll() You previously would not encounter any issues, this exists in some generalised "run this sql" code. As of PHP 7.4.13, this will now throw an error "General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute" This also fails on PHP 8, but as that lies over a BC boundary, that seems reasonable. Test script: --------------- script.php <?php $pdo = new \PDO("mysql:host=my-hostname;dbname=testcase", "username", "password, [ PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, ]); $pdo->exec("DROP TABLE IF EXISTS users"); $pdo->exec("CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY,name TEXT)"); $sql = "DELETE FROM `users`"; $statement = $pdo->prepare($sql); print_r($statement->execute()); print_r($statement->fetchAll()); run.sh: #!/usr/bin/env sh docker-php-source extract docker-php-ext-install pdo_mysql php script.php command to isolate it as 12 vs 13: docker run -it -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7.4.12-cli-alpine ./run.sh docker run -it -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7.4.13-cli-alpine ./run.sh Expected result: ---------------- I'd expect it to not throw an error. Actual result: -------------- It throws an error