php/php-src — pull request #108 by ircmaxell (2012-06-15 00:57:46+00:00)
Title: Change default value for PDO_Mysql driver ATTR_EMULATE_PREPARES to off

This pull request changes the default value for PDO_Mysql to disable prepared statement emulation. It can still be turned on with `$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true)`.

This fixes issue https://bugs.php.net/bug.php?id=54638

Quoting:

The PDO_MySQL driver defaults emulate_prepare to 1, which forces all prepared
queries to be emulated by the driver. This means that even though the client
library (mysqlnd or libmysql) may support prepared statements, PDO will never
really use them.

You can set the attribute PDO::ATTR_EMULATE_PREPARES to 0, and it prepares and
executes the prepared statements just fine using the native mode (rather than
emulation). However this is not documented at all on PHP.NET.

Since PDO_MYSQL will fallback to emulation automatically if the client library or
server are too old for prepared statements, I would suggest that the default
value for emulate_prepare should be set to 0 to allow for true prepared
statements.