PHP 5, MySQL, Windows & Stored procedures
For people like me who develop on and for windows (at times) and who like to use MySQL’s stored procedures here’s a quick tip.
Some PHP versions give the following warning when you call stored procedures in PDO.
For example:
$statement = $pdo->prepare("CALL my_proc(?)");
$statement->execute(array($myVar));
Can result in the following error:
code: HY000, msg: 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.
To work around this you need to reinitialize your database connection every time you’ve called a stored procedure on windows.
For as far as I can tell this is the result of a bug in the windows version of the MySQL PDO driver. More details here.
No Comments »
RSS feed for comments on this post. TrackBack URL