我通读了其他答案,大多数答案都是通过添加 $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);
还有什么需要帮忙的吗? 谢谢
最佳答案
将 closeCursor() 移到 if 之外,以便始终执行它。
$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();
关于php - 一般错误 2014 在 closeCursor() 之后仍然发生,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19544177/