I have this very simple MCVE where even no table/database is affected:
<?php
$pdoConnection = new PDO( "mysql:host=<hostname>", "<user>", "<pwd>" );
$pdoConnection->setAttribute( PDO::ATTR_EMULATE_PREPARES, TRUE );
$command = $pdoConnection->prepare("SELECT IF('1', -:foo, :foo) AS FOO");
$command->bindValue( "foo", 1, PDO::PARAM_INT );
$command->execute();
echo "<pre>";
print_r($command->fetch(PDO::FETCH_ASSOC));
?>
The result is as expected:
Array
(
[FOO] => -1
)
Disabling the prepare emulation with
$pdoConnection->setAttribute( PDO::ATTR_EMULATE_PREPARES, TRUE );
breaks totally the code. No error and also no output as nothing has been executed even it is a regular and correct MySQL code.
My questions:
- Is there a legal reason why there is no result, or
- is it a bug, but what causes the bug? PHP or MySQL?
Versions:
- OS: SLES 12.3
- PHP: 7.2.9
- MySQL 8.0.12