4

i had a read through the other answers and most were resolved by adding the $sth->closeCursor(); I have multiple calls to sprocs after each other and still getting the error on each of them.

Here my code:

 <?php
 $sql = "CALL get_salesquote_lineitems(:salesquoteguid);";
 $array = array('salesquoteguid' => $salesquoteguid);
 $sth = $dbh->prepare($sql);
 if ($sth->execute($array)) {
     $lineItems = $sth->fetchAll(PDO::FETCH_ASSOC);
     $sth->closeCursor();
 }

 $sql = "CALL get_salesquote_totals(:salesquoteguid);";
 $array = array('salesquoteguid' => $salesquoteguid);
 $sth = $dbh->prepare($sql);
 if ($sth->execute($array)) {
    $totalData = $sth->fetchAll(PDO::FETCH_ASSOC);
    $sth->closeCursor();
 }

 $sql = "CALL get_salesquote_data(:salesquoteguid);";
 $array = array('salesquoteguid' => $salesquoteguid);
 $sth = $dbh->prepare($sql);
 if ($sth->execute($array)) {
    $quoteData = $sth->fetchAll(PDO::FETCH_ASSOC);
    $sth->closeCursor();
 }

 $sql = "CALL get_salesquote_warranty_rows(:salesquoteguid);";
 $array = array('salesquoteguid' => $salesquoteguid);
 $sth = $dbh->prepare($sql);
 if ($sth->execute($array)) {
    $warrantyRows = $sth->fetchAll(PDO::FETCH_ASSOC);
    $sth->closeCursor();
 }

i also tried:

  $cn->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);

any further help please? thanks

charlie_cat
  • 1,830
  • 7
  • 44
  • 73
  • I thought you'd like to know I spent some time setting this up on my test server and couldn't duplicate your problem. This leads me to suspect either a problem with your stored procedures, or some issue with the volume of data you're returning. –  Oct 27 '13 at 04:12
  • thanks very much. Some one sorted it for me here at the office :) – charlie_cat Oct 30 '13 at 09:25

1 Answers1

0

Move the closeCursor() outside the if so it is always executed.

$sql = "CALL get_salesquote_totals(:salesquoteguid);";
$array = array('salesquoteguid' => $salesquoteguid);
$sth = $dbh->prepare($sql);
if ($sth->execute($array)) {
   &nbsp;&nbsp;$totalData = $sth->fetchAll(PDO::FETCH_ASSOC);
}
$sth->closeCursor();
wclark
  • 436
  • 4
  • 14