I am trying to execute many select statements in mysql in a single query using php.
select * from clients;
select * from users;
select * from products;
Mysql workbench returns only the records of the last sql statement. My PHP code is
$query = "select * from table1;select * from table2;"
$result = $pdo->prepare($query);
$result->execute();
$rows = $result->fetchAll(PDO::FETCH_NAMED);
I get the error
SQLSTATE[HY000]: 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
Is it possible to execute multiple select queries at once and get all results like MSSQL does?
My only workaround for the moment is to loop through single sql executions and build the response dynamically.