note 80306 added to ref.pdo-mysql
| From: | rmottey at gmail dot com | Date: | Wed, 09 Jan 2008 11:51:29 +0000 |
| Subject: | note 80306 added to ref.pdo-mysql | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-134967@lists.php.net to get a copy of this message | ||
I have been getting the error below when performing multiple queries within a single page.
Setting the attribute below did not seem to work for me.
So building on previous example i am initilizing my stmt variable on every query and a fetch all
into an array. Seems to be working for me.
Error:
PDO Error 1.1: Array ( [0] => xxx[1] => yyy[2] => Lost connection to MySQL server during
query )
Fix:
(PDO::setAttribute("PDO::MYSQL_ATTR_USE_BUFFERED_QUERY", true);)
<?
try {
$dbh = new PDO('mysql:host=xxx;port=xxx;dbname=xxx', 'xxx',
'xxx', array( PDO::ATTR_PERSISTENT => false));
$stmt = $dbh->prepare("CALL getname()");
// call the stored procedure
$stmt->execute();
// fetch all rows into an array.
$rows = $stmt->fetchAll();
foreach ($rows as $rs)
{
$id = $rs['id'];
}
//initilise the statement
unset($stmt);
$stmt = $dbh->prepare("call secondprocedure(?);");
$stmt->bindValue(1, $id);
if ( ! $stmt->execute() )
{
echo "PDO Error 1.1:\n";
print_r($stmt->errorInfo());
exit;
}
unset($stmt);
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
----
Server IP: 194.145.210.3
Probable Submitter: 86.136.138.151
----
Manual Page -- http://www.php.net/manual/en/ref.pdo-mysql.php
Edit -- https://master.php.net/note/edit/80306
Del: integrated -- https://master.php.net/note/delete/80306/integrated
Del: useless -- https://master.php.net/note/delete/80306/useless
Del: bad code -- https://master.php.net/note/delete/80306/bad+code
Del: spam -- https://master.php.net/note/delete/80306/spam
Del: non-english -- https://master.php.net/note/delete/80306/non-english
Del: in docs -- https://master.php.net/note/delete/80306/in+docs
Del: other reasons-- https://master.php.net/note/delete/80306
Reject -- https://master.php.net/note/reject/80306
Search -- https://master.php.net/manage/user-notes.php