2014-03-26 72 views
2

我很努力地使用返回多個結果集的MYSQL(5.5.35)存儲過程,我想知道是否有人能解釋發生了什麼問題。該SQL是按以下MYSQL + PDO nextRowSet循環多次?

SELECT 't1' as tableName, tbl1.* FROM table1 tbl1; 
SELECT 't2' as tableName, tbl2.* FROM table2 tbl2; 
SELECT 't3' as tableName, tbl3.* FROM table3 tbl3; 
SELECT 't4' as tableName, tbl4.* FROM table4 tbl4; 
SELECT 't5' as tableName, tbl5.* FROM table5 tbl5; 
SELECT 't6' as tableName, tbl6.* FROM table6 tbl6; 

然後,我有一些PHP,這是否......

$sth =$dbh->prepare('CALL getAllRecords()'); 
$sth->execute(); 

$i = 1; 
do { 
    echo "<h3>$i Set</h3>"; 
    $i++; 
    $rows = $sth->fetchAll(); 
} while ($sth->nextRowset()); 

人們會期望看到在瀏覽器中以下

1 Set 
.. 
6 Set 

但相反,它運行7個結果集,這反過來引起異常

Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error' 

我在這裏錯過了一些非常簡單的東西嗎?

+0

哪一行引發異常?使用fetchall? –

+0

是的,它是fetchAll – Zoidberg

+0

我不認爲自己是任何意義上的專家,但我可以誠實地看不到任何明顯錯誤的代碼。 –

回答