Skip to content
PHP Logo

How does the behavior of PDO change when setting ATTR_EMULATE_PREPARES to false in PHP?

When setting ATTR_EMULATE_PREPARES to false in PHP PDO, it disables the emulation of prepared statements by the PDO MySQL driver. This means that the PDO driver will use native prepared statement support provided by the database server, resulting in improved security and performance.

php
$pdo = new PDO("mysql:host=localhost;dbname=mydatabase", "username", "password");
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);