Enabling MySQL Query Cache with Zend Framework through PDO::MYSQL_ATTR_USE_BUFFERED_QUERY

It’s interesting that if you read through the Zend dB manual, they mention a big problem with Zend Framework, namely that since Zend uses prepared statements, if you’re running a pre-5.1.17 version of MySQL, you give up the benefits of MySQL’s query cache. They also provide the solution in one of their examples, but they neglect to tell you that it solves the problem.

If you look at example 11.7:

$pdoParams = array(
    PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true
);

you will find setting this parameter when starting the connection turns on the query cache.

About these ads

3 responses to “Enabling MySQL Query Cache with Zend Framework through PDO::MYSQL_ATTR_USE_BUFFERED_QUERY

  1. I had this same problem, you need to replace the DLL from a DLL php_pdo_mysql.dll unofficial found on this site: http://www.emilianbalanescu.ro/tshirtshop/pdo_driver/php_pdo_mysql.dll
    Good luck

  2. Have you got some backup to show that the link is legit? (I didn’t follow the link myself…) If no one comes through w/ some proof I’m going to put the post back into spam…

  3. In case you wonder how to enable it from application.ini

    resources.db.params.driver_options[1000] = true

    Note that PDO::MYSQL_ATTR_USE_BUFFERED_QUERY instead of 1000 does not work since it gets resolved to string instead of constant.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s