Change default value for PDO_Mysql driver ATTR_EMULATE_PREPARES to off #108
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.