I\'m experiencing what appears to be a bug using a PDO statement to make multiple selects.
I\'m building a SQL query that has many SELECTs, and regardless of how ma
To avoid that PDOException
just use columnCount
:
while ($statment->columnCount()) {
$rowset = $statment->fetchAll(PDO::FETCH_ASSOC);
$statment->nextRowset();
}
I think you are over complicating things with your do/while loop.
Try a simple while loop instead:
$pdo = /* connection stuff here */
$sql = "select 1; select 2; select 3; select 4;";
$statement = $pdo->query($sql);
while($rowset = $statement->fetchAll()){
//do stuff
$statement->nextRowset();
}
This will continue looping while rowset does not have a false value which should then work exactly as you expect.