note 84588 added to ref.pdo-mysql

From: Date: Sun, 20 Jul 2008 21:03:04 +0000
Subject: note 84588 added to ref.pdo-mysql
Groups: php.notes 
Request: Send a blank email to php-notes+get-142337@lists.php.net to get a copy of this message
SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. ... This one can be a royal pain to deal with. Never stack statements to be executed in one go. Nobody ever mentions this possibility in all the posts I've seen dealing with this error. This example is a Zend Framework example but the theory is the same. As in: $sql = <<<____SQL CREATE TABLE IF NOT EXISTS ticket_hist ( tid int(11) NOT NULL, trqform varchar(40) NOT NULL, trsform varchar(40) NOT NULL, tgen datetime NOT NULL, tterm datetime, tstatus tinyint(1) NOT NULL ) ENGINE=ARCHIVE COMMENT='ticket archive'; CREATE TABLE IF NOT EXISTS request_hist ( rqid int(11) NOT NULL, rqtid int(11) NOT NULL, rqsid int(11) NOT NULL, rqdate datetime NOT NULL, rqcode tinyint(1) NOT NULL, rssid int(11) NOT NULL, rsdate datetime, rscode tinyint(1) ) ENGINE=ARCHIVE COMMENT='request archive'; CREATE TABLE IF NOT EXISTS relay_hist ( rqid int(5) NOT NULL, sdesc varchar(40) NOT NULL, rqemail varchar(40) NOT NULL, sid int(11) NOT NULL, rlsid int(11) NOT NULL, dcode varchar(5) NOT NULL ) ENGINE=ARCHIVE COMMENT='relay archive'; ____SQL; $result = $this->db->getConnection()->exec($sql); This will run fine but PDO will balk with the 'unbuffered' error if you follow this with another query. Instead do: $sql = <<<____SQL CREATE TABLE IF NOT EXISTS ticket_hist ( tid int(11) NOT NULL, trqform varchar(40) NOT NULL, trsform varchar(40) NOT NULL, tgen datetime NOT NULL, tterm datetime, tstatus tinyint(1) NOT NULL ) ENGINE=ARCHIVE COMMENT='ticket archive'; ____SQL; $result = $this->db->getConnection()->exec($sql); $sql = <<<____SQL CREATE TABLE IF NOT EXISTS request_hist ( rqid int(11) NOT NULL, rqtid int(11) NOT NULL, rqsid int(11) NOT NULL, rqdate datetime NOT NULL, rqcode tinyint(1) NOT NULL, rssid int(11) NOT NULL, rsdate datetime, rscode tinyint(1) ) ENGINE=ARCHIVE COMMENT='request archive'; ____SQL; $result = $this->db->getConnection()->exec($sql); $sql = <<<____SQL CREATE TABLE IF NOT EXISTS relay_hist ( rqid int(5) NOT NULL, sdesc varchar(40) NOT NULL, rqemail varchar(40) NOT NULL, sid int(11) NOT NULL, rlsid int(11) NOT NULL, dcode varchar(5) NOT NULL ) ENGINE=ARCHIVE COMMENT='relay archive'; ____SQL; $result = $this->db->getConnection()->exec($sql); Chopping it into individual queries fixes the problem. ---- Server IP: 69.147.83.197 Probable Submitter: 69.110.47.49 ---- Manual Page -- http://www.php.net/manual/en/ref.pdo-mysql.php Edit -- https://master.php.net/note/edit/84588 Del: integrated -- https://master.php.net/note/delete/84588/integrated Del: useless -- https://master.php.net/note/delete/84588/useless Del: bad code -- https://master.php.net/note/delete/84588/bad+code Del: spam -- https://master.php.net/note/delete/84588/spam Del: non-english -- https://master.php.net/note/delete/84588/non-english Del: in docs -- https://master.php.net/note/delete/84588/in+docs Del: other reasons-- https://master.php.net/note/delete/84588 Reject -- https://master.php.net/note/reject/84588 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#142337) next »