Prepared PDO messages that do not emulate

I've read several times that by default PDO doesn't use its own prepared statements, but prefers to mimic them. To include true prepared statements, you can add:

$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

      

I've also read that this is the case for MySQL, but not PostgreSQL.

One place I really expected to read is the PHP website, but I don't mention it at all.

The closest I can find from http://php.net/manual/en/pdo.prepare.php :

PDO will emulate prepared statements / bound options for drivers that do not support them, and may also overwrite name or question style option markers to something more appropriate if the driver supports one style but not the other.

At http://www.php.net/manual/en/ref.pdo-mysql.php it says:

PDO_MYSQL will use the built-in operator support introduced in MySQL 4.1 and later. If you are using an older version of the mysql client libraries, PDO will mimic them for you.

Personally, I prefer to use true prepared statements, so it's easy enough to fix, especially in 2017 when the database support is pretty good.

This begs the question: where is it documented what PDO default fit prepares? Also, does this apply to all databases or some?

Note. There is an existing question. Does PDO use emulated prepared statements by default? ... This is not a duplicate (I read this already):

  • Question 5 years
  • Links are dead
  • There is dissent in the comments.

This question doesn't tell me where it is actually documented.

+3


source to share





All Articles