Bug #77823 [Opn]: Constant MYSQL_ATTR_MULTI_STATEMENTS not supported

From: Date: Mon, 01 Apr 2019 15:43:14 +0000
Subject: Bug #77823 [Opn]: Constant MYSQL_ATTR_MULTI_STATEMENTS not supported
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220282@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77823&edit=1 ID: 77823 Updated by: johannes@php.net Reported by: alan at aondra dot com Summary: Constant MYSQL_ATTR_MULTI_STATEMENTS not supported Status: Open Type: Bug Package: PDO MySQL Operating System: Windows 10 x64 PHP Version: 7.3.3 Block user comment: N Private report: N New Comment: I haven't checked the flag and whether we could add explicit support, but pdo_mysql defaults to multi_statement mode as that is needed for calling stored procedures which users expected to work by default. <?php $dsn = 'mysql:host=127.0.0.1:3380'; $username = 'native'; $password = ''; $db = new PDO($dsn, $username, $password, [ PDO::ATTR_EMULATE_PREPARES => true, PDO::ATTR_AUTOCOMMIT => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_MULTI_STATEMENTS => true, ]); $stmt = $db->query('SELECT 1; SELECT 2;'); var_dump($stmt->fetchAll()); $stmt->nextRowset(); var_dump($stmt->fetchAll()); ?> array(1) { [0]=> array(2) { [1]=> string(1) "1" [2]=> string(1) "1" } } array(1) { [0]=> array(2) { [2]=> string(1) "2" [3]=> string(1) "2" } } Previous Comments: ------------------------------------------------------------------------ [2019-03-29 16:20:32] alan at aondra dot com Description: ------------ PDO does not support running multiple queries out of the box. Installed 7.3.3 x64 TS. This also goes back to at least 7.3.0. Test script: --------------- $db = new PDO($dsn, $username, $password, [ PDO::ATTR_EMULATE_PREPARES => true, PDO::ATTR_AUTOCOMMIT => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_MULTI_STATEMENTS => true, ]); // mysqlnd 5.0.12-dev - 20150407 - $Id: 7cc7cc96e675f6d72e5cf0f267f48e167c2abb23 $ echo $db->getAttribute(PDO::ATTR_CLIENT_VERSION) . PHP_EOL; // PDOException#0: SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute echo $db->getAttribute(PDO::MYSQL_ATTR_MULTI_STATEMENTS) . PHP_EOL; $stmt = $db->query('SELECT 1; SELECT 2;'); // SELECT 1; SELECT 2; echo $stmt->queryString . PHP_EOL; Expected result: ---------------- I expect that the query be executed as multiple queries, with each result being a rowset, and each rowset having a non-zero number of rows. Actual result: -------------- An empty result, or a PDOException being thrown for multiple queries being incorrect syntax (depending on other configurations). ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77823&edit=1

« previous php.bugs (#220282) next »