Answer the question
In order to leave comments, you need to log in
PHP+PDO Mysql, query not executed after exec with multiple queries inside?
After executing a request like
$db->exec('UPDATE as SET b=c WHERE d=1; UPDATE as SET b=e WHERE d=2; UPDATE as SET b=f WHERE d=3');<br>
$db->query('SELECT * FROM e') ;<br>
Array<br>
(<br>
[0] => HY000<br>
[1] => 2014<br>
[2] => 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.<br>
)<br>
Answer the question
In order to leave comments, you need to log in
The solution turned out to be obvious. Instead of
$db->exec('UPDATE as SET b=c WHERE d=1; UPDATE as SET b=e WHERE d=2; UPDATE as SET b=f WHERE d=3');
$db->query('UPDATE as SET b=c WHERE d=1; UPDATE as SET b=e WHERE d=2; UPDATE as SET b=f WHERE d=3')->fetchAll(PDO::FETCH_NUM);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question