Can I use real prepared MySQL statements with PDO now?

5 years ago (really!) Wez Furlong was a lead developer of PDO, and he wrote this:

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

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

This leads to the fact that it uses its own PDO request parser instead of the built-in prepared API instructions in the mysql client and effectively fixes these problems.

The rationale is given at http://wezfurlong.org/blog/2006/apr/using-pdo-mysql/

However, he could not answer if the problems were fixed now when the PDO uses Mysqlnd (at least I assume that it is).

Somebody knows?

+5
source share
1 answer

Yes, if you set ATTR_EMULATE_PREPARESto false(or 0), it will use real prepared statements.

Grade. He still has his own logic. Therefore, although mysqli :: prepare failed, if the preparation from the server failed, the PDO will not, because it will return to the preparation emulation. The reason for this is that PDO can use prepared statements in versions of MySQL that do not support it, as well as for statements (for example ALTER) that do not support preparation.

, , MySQL ( , ATTR_EMULATE_PREPARES - false)...

+6

All Articles