|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-08-08 13:44 UTC] michael dot kofler at gmx dot com
Description:
------------
mysqli::multi_query returns FALSE if more than one query is given
Reproduce code:
---------------
$mysqli = new mysqli($mysqlhost, $mysqluser, $mysqlpasswd, $mysqldb);
$sql = "SELECT 1; SELECT 2; SELECT 3";
$ok = $mysqli->multi_query($sql);
if($ok === FALSE) {
echo $mysqli->error();
}
Expected result:
----------------
non (because $ok === TRUE)
(works with mysqli + libmysql)
Actual result:
--------------
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; SELECT 2; SELECT 3' at line 1
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 07:00:01 2025 UTC |
also does not work with PDO: $sql = "SELECT 1; SELECT 2; SELECT 3"; $result = $conn->query($sql); do { echo "<p>----\n"; $rowset = $result->fetch(PDO::FETCH_NUM); foreach($rowset as $row) { echo "<p>$row[0]"; } } while($result->nextRowset()); Expected result (which I get with libmysql) ---- 1 ---- 2 ---- 3 Actual result (with myslqnd, apparently only the first SQL command is evaluated) ---- 1(some debug output from my hacked php5.3 included) nixnutz@ulflinux:~/src/php5> sapi/cli/php -i | grep configure Configure Command => './configure' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--with-pdo-mysql=/usr/local/mysql/bin/mysql_config' nixnutz@ulflinux:~/src/php5> sapi/cli/php -r '$p = new PDO("mysql:host=localhost;db=test", "root", "root"); $stmt = $p->query("SELECT 1; SELECT 2; SELECT 3"); do { var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); } while ($stmt->nextRowset());' fetch_value(0) param_str array(1) { [0]=> array(1) { [1]=> string(1) "1" } } fetch_value(0) param_str array(1) { [0]=> array(1) { [2]=> string(1) "2" } } fetch_value(0) param_str array(1) { [0]=> array(1) { [3]=> string(1) "3" } } nixnutz@ulflinux:~/src/php5> sapi/cli/php -i | grep configure Configure Command => './configure' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' nixnutz@ulflinux:~/src/php5> sapi/cli/php -r '$p = new PDO("mysql:host=localhost;db=test", "root", "root"); $stmt = $p->query("SELECT 1; SELECT 2; SELECT 3"); do { var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); } while ($stmt->nextRowset());' fetch_value(0) param_str array(1) { [0]=> array(1) { [1]=> string(1) "1" } } fetch_value(0) param_str array(1) { [0]=> array(1) { [2]=> string(1) "2" } } fetch_value(0) param_str array(1) { [0]=> array(1) { [3]=> string(1) "3" } }