This is a more modern answer to this question.
The old way to prevent multiple queries from executing was to disable emulated prepares, however this only applies to the PDO::prepare() method. In newer versions of PHP (> = 5.5.21 and> = 5.6.5), a new constant has been introduced to disable this multi-process execution in both PDO::prepare() and PDO::query() . (Constants are not usually added in patch versions, but this was done due to the severity of the Drupal SQL injection attack caused by this feature).
The new constant PDO::MYSQL_ATTR_MULTI_STATEMENTS should be set when creating the object (as the fourth argument to the PDO constructor) - setting it to an existing object using PDO::setAttribute() will not work.
$pdo = new PDO('mysql:host=_;dbname=_', '', '', [PDO::MYSQL_ATTR_MULTI_STATEMENTS => false]);
tpunt
source share