As of PHP version 5.3 PDO_MYSQL
driver has been repleaced in favour of PDO_MYSQLND
. It introduced support for multiple queries.
Though, I c
It turns out that you need to use PDOStatement::nextRowset
.
$stmt = $db->query("SELECT 1; SELECT 2;");
$stmt->nextRowset();
var_dump( $stmt->fetchAll(PDO::FETCH_ASSOC) );
This will return result for the second query.
It is a bit odd implementation. It would certainly be easier if multi-query statement would just return both results sets under one array. However, the advantage is that this implementation allows to fetch every query using different FETCH styles.