php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #77031 ATTR_EMULATE_PREPARES and multiquery
Submitted: 2018-10-18 09:48 UTC Modified: 2021-07-06 17:04 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: giolaza at gmail dot com Assigned:
Status: Open Package: PDO MySQL
PHP Version: 7.2.11 OS: Windows, Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: giolaza at gmail dot com
New email:
PHP Version: OS:

 

 [2018-10-18 09:48 UTC] 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 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-06 17:04 UTC] cmb@php.net
-Type: Bug +Type: Documentation Problem
 [2021-07-06 17:04 UTC] cmb@php.net
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>
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Sep 25 19:03:38 2021 UTC