In the content linked below, Tom says setting id = :id can’t be used, because it has already been used in the query, and each parameter needs a unique name
However, each PDO parameter does not need a unique name if emulation mode is on, according to https://www.php.net/manual/en/pdo.prepare.php
It seems that emulation mode is on by default (using Docker). However, if we add this to the end of the DatabaseConnection.php
$pdo->setAttribute( PDO::ATTR_EMULATE_PREPARES, false );
then emulation mode is off, and we really can’t reuse :id and must set id
= :primaryKey’ and set a value for primaryKey.
My question is, what is emulation mode, simply?
Is there any drawback to setting emulation mode explicitly to true, and re-using parameters?
Link to content: PHP & MySQL: Novice to Ninja, 7th Edition - Section 7