php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #48859 PDO mysql does not support multiple inital queries
Submitted: 2009-07-08 22:59 UTC Modified: 2010-09-06 10:59 UTC
Votes:9
Avg. Score:2.3 ± 1.6
Reproduced:5 of 5 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (40.0%)
From: techi at techi dot name Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 5.2.10 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: techi at techi dot name
New email:
PHP Version: OS:

 

 [2009-07-08 22:59 UTC] techi at techi dot name
Description:
------------
When using intial SQL query with PDO::MYSQL_ATTR_INIT_COMMAND, only one 
query can be queried. More queries throws exception SQLSTATE[HY000]: 
General error: 2014

I am not sure, if this is bug or feature or some PDO limitation, but 
sometimes more than one initial query is needed

Reproduce code:
---------------
$pdo = new PDO( 
    'mysql:host=hostname;dbname=defaultDbName', 
    'username', 
    'password', 
    array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8;SET time_zone = 'Europe/Prague'") 
); 


Actual result:
--------------
SQLSTATE[HY000]: General error: 2014

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-22 07:46 UTC] kalle@php.net
The question here is trival, because internally we use mysql_options(MYSQL_INIT_COMMAND) which does not support multiple queries then. We could probably work around it with some hackish code, but I'll leave this up to the mysql guys to judge
 [2009-11-19 00:12 UTC] Ivo at UFO-Net dot nl
The following workaround works for me:
SET NAMES utf8,time_zone = '+0:00'

This is possible at least for SET commands. More information about SET is available in the MySQL manual: http://dev.mysql.com/doc/refman/5.1/en/set-option.html. It states that "A SET  statement can contain multiple variable assignments, separated by commas."
 [2010-09-06 10:59 UTC] uw@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2010-09-06 10:59 UTC] uw@php.net
It is a security and portability matter: you do not want to allow the execution of multiple statement per one operation by default. It opens up the door for SQL injection. Disabling the feature by default is also what mysqli does. 

Also, it is a matter of portability - shouldn't PDO try to use portable defaults?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 07:01:32 2024 UTC