PDO out of memory fix

If your having issues with large PDO query sizes in PHP and getting out of memory issues the solution is to set PDO::MYSQL_ATTR_USE_BUFFERED_QUERY to false

refer below example

$pdo = new PDO('mysql:host=', 'foo', 'bar', array(
$pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);

For whatever reason on certain system even small queries can bomb out - just add in this attribute and your queries should now run fine in PDO

Justin Kelly

Justin Kelly

Web Developer, Business Analytics, Data Engineer specialising in PHP and Tableau

Based in Melbourne, Australia

Feel free to contact me justin@kelly.org.au or _justin_kelly

Leave a comment

Notify me of replies by email.