General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.PDO - 使用fetchall語法不起作用
我的代碼: - 創建一個選擇標籤和數據庫
<?php
echo "<select name='test'>";
$call = $dbh->prepare('call listmfg_codes()');
$call->execute();
$result = $call->fetchALL(PDO::FETCH_COLUMN, 0);
foreach($result as $row)
{
?>
<option value="<?php echo $row['mfg_code'];?>"><?php echo $row['mfg_code'];?> </option>";
<?php
}
echo "</select>";
?>
與記錄填充它,它似乎並沒有工作。請指教。謝謝
然後我試圖再次修改腳本,以適應closeCurosr()和fetchAll()。它仍然不起作用
<?php
....
$stmt_call -> closeCursor();
echo "<select name='test'>";
$stmt_call = $dbh->prepare('call listmfg_codes()');
$stmt_call->execute();
foreach ($stmt_call -> fetchAll() as $row)
{
?>
<option value="<?php echo $row['mfg_code'];?>"> <?php echo $row['mfg_code'];?> </option>";
<?php
}
echo "</select>";
?>
即使包含了fetchAll()和closeCursor(),同樣的錯誤仍然存在。
我仍在尋找stachOverFlow之外的答案。請指教謝謝 克萊門特
http://stackoverflow.com/questions/2421516/how-to-avoid-this-pdo-exception-cannot-execute-queries-while-other-unbuffered-q – Rikesh 2013-02-20 11:06:29
的可能重複的究竟是什麼'調用listmfg_codes()'? – 2013-02-20 14:08:15
它是mysql程序,被這個腳本調用來執行 - 「從測試中選擇distinct(mfg_code);」 – user1739825 2013-02-21 00:53:19