Wez Furlong I am Wez Furlong, Chief Software Architect at Message Systems, PHP Core developer and OpenSource contributor. I live in Maryland, USA with Juliette, Xander and Lily. (read more)

Subscribe to my blog  

Follow wezfurlong on Twitter

Using PDO::MYSQL ?

PHP
Apr 22, 2006
Updated Apr 22, 2006

I've recently discovered a few things about how the mysql client library does things that seem a bit silly to me, so I'm going to share them with you.

I recommend that you use the following attribute when working with PDO::MYSQL, available in the current PHP 5.1.3 release candidates and snapshots:

$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);

This causes the PDO native query parser to be used instead of the native prepared statements APIs in the mysql client, and effectively eliminates those problems.

I'll admit that the last point could well be a bug in my code; since I'll be at the MySQL Users Conference next week, I should be able to sit down with the right people and fix it.

Comments