5

I have copied unmodified (I think) code for Yii's database connection from manual / demo app / whatever. And, if I'm not mistaken, it has 'emulatePrepare'=>TRUE set by default.

Then I found this and this answer and many more sources, which all seems to be claiming, that using emulate prepares is wrong idea. That it is some kind of relic from an old versions of RDBMS (particularly MySQL in my case) and should not be used on modern versions of MySQL/PHP.

Can someone confirm that? Should we have 'emulatePrepare'=>FALSE in our Yii apps?

Community
  • 1
  • 1
trejder
  • 17,148
  • 27
  • 124
  • 216

1 Answers1

6

Both answers you have linked to are quite pointless and subjective. They fail to provide a certain reason for avoiding emulation mode. No wonder though, as there is not a single one.

There are only two real live cases known to me which really affects experience with PDO

  • when emulation is turned on, then one cannot use passing parameter in execute() for the LIMIT statement.
  • when emulation is turned off, then one cannot use quite handy feature of using more than one named placeholder with same name.

So, the final decision is up yo you, but I wouldn't call any issue too critical.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
  • Thank you. So, from your answer, it seems, that claims like: "_emulate prepare was good for old versions of RDBMs, but for modern ones it is just slower_" (found at least few of them), we should treat like blah-blah, right? – trejder Apr 26 '14 at 15:35
  • This particular one is rather not true. As it (properly) noted in the other answer, it's quite contrary - `"native prepared statements may be a little slower than issuing a plain textual query using emulated prepared statements."` – Your Common Sense Apr 26 '14 at 15:39
  • Plus: there is [this answer](http://stackoverflow.com/a/8776392/1469208): "_`EMULATE_PREPARES=true` seems to be the default setting for the pdp_mysql driver right now. The query cache thing has been fixed/change since then (...)_". Thanks, again! – trejder Apr 26 '14 at 15:42
  • This one is rather irrelevant. Query cache issue were applicable only to `emulate=>FALSE` case (making it even slower). But it is fixed nowadays anyway. – Your Common Sense Apr 26 '14 at 15:50