Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To use "emulatePrepare" in Yii or not?

Tags:

php

mysql

pdo

yii

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?

like image 790
trejder Avatar asked Apr 26 '14 14:04

trejder


1 Answers

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.

like image 56
Your Common Sense Avatar answered Sep 24 '22 11:09

Your Common Sense