【问题标题】:General error 2014 still happening after closeCursor()在 closeCursor() 之后仍然发生一般错误 2014
【发布时间】:2013-10-23 14:13:01
【问题描述】:

我阅读了其他答案,大多数都通过添加 $sth->closeCursor(); 解决了。 我对 sprocs 进行了多次调用,但每个调用仍然出现错误。

这是我的代码:

 <?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();
 }

我也试过了:

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

请问有什么进一步的帮助吗? 谢谢

【问题讨论】:

  • 我想你想知道我花了一些时间在我的测试服务器上设置它并且无法复制你的问题。这使我怀疑您的存储过程存在问题,或者您返回的数据量存在问题。
  • 非常感谢。有人在办公室为我整理过 :)

标签: php mysql pdo


【解决方案1】:

将 closeCursor() 移到 if 之外,所以它总是被执行。

$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();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-03
    • 2015-08-21
    • 1970-01-01
    • 1970-01-01
    • 2014-05-07
    • 1970-01-01
    相关资源
    最近更新 更多