I am struggling with a MYSQL (5.5.35) stored procedure that returns multiple result sets, I wonder if anyone can explain what is going wrong. The SQL is as per the following
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;
Then I have some PHP that does this...
$sth =$dbh->prepare('CALL getAllRecords()');
$sth->execute();
$i = 1;
do {
echo "<h3>$i Set</h3>";
$i++;
$rows = $sth->fetchAll();
} while ($sth->nextRowset());
One would expect to see the following in the browser
1 Set
..
6 Set
But instead it runs through 7 result sets which in turn causes an exception
Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error'
Am I missing something really simple here?