2013-10-23 56 views
4

我讀過其他答案,並通過添加$ sth-> closeCursor(); 我有多次調用sprocs對方後,仍然得到他們每個人的錯誤。一般錯誤2014年後仍然發生closeCursor()

這裏我的代碼:

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

任何進一步的幫助嗎? 謝謝

+0

我以爲你想知道我花了一些時間在我的測試服務器上設置它,並且無法複製你的問題。這導致我懷疑存儲過程有問題,或者您返回的數據量有問題。 – 2013-10-27 04:12:07

+0

非常感謝。有人在辦公室爲我分類:) –

回答

0

將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(); 
相關問題