Edit report at https://bugs.php.net/bug.php?id=77031&edit=1
ID: 77031
Updated by: cmb@php.net
Reported by: giolaza at gmail dot com
Summary: ATTR_EMULATE_PREPARES and multiquery
Status: Open
-Type: Bug
+Type: Documentation Problem
Package: PDO MySQL
Operating System: Windows, Linux
PHP Version: 7.2.11
Block user comment: N
Private report: N
New Comment:
PDO::query() is a shortcut for PDO::prepare() and PDO::execute().
mysql_prepare() only supports a single statement[1]; that's why
you're getting an error. Emulated prepares, on the other hand,
don't mind multiple statements (unless
PDO::MYSQL_ATTR_MULTI_STATEMENTS => false), so this works.
I think we should document this.
[1] <https://dev.mysql.com/doc/c-api/8.0/en/mysql-stmt-prepare.html>
Previous Comments:
------------------------------------------------------------------------
[2018-10-18 09:48:16] giolaza at gmail dot com
Description:
------------
PDO::ATTR_EMULATE_PREPARES and connect->quety('UPDATE 1 SLQ; UPDATE 2 SQL') problem
Test script:
---------------
$this->connect->setAttribute(\PDO::ATTR_EMULATE_PREPARES,false);
$q2=[];
$q2[]='UPDATE users set
has_trialPeriod=0,last_changedBalance=1539846901 where id=1';
$q2[]='UPDATE users set
balance_usd=(balance_usd-99990000) where id=1';
$q=implode(';', $q2);
$this->connection->query($q);
got err
Actual result:
--------------
GOT SQL ERR
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77031&edit=1