Home:ALL Converter>Why cannot disable PDO::ATTR_EMULATE_PREPARES?

Why cannot disable PDO::ATTR_EMULATE_PREPARES?

Ask Time:2011-12-26T22:05:09         Author:zac1987

Json Formatter

I am using PHP 5.2.9 and Apache 2.2.11 and mysql 5.1.32

Why I cannot disable PDO::ATTR_EMULATE_PREPARES ?

Below is the code :

<?php
try{
    $conn = new PDO("mysql:host=$DB_SERVER;dbname=$DB_NAME",$DB_USER,$DB_PASS, array(PDO::ATTR_EMULATE_PREPARES => false)); 
}

catch(PDOException $pe){
    die('Connection error : ' .$pe->getMessage());
}

$st = $conn->prepare('abc');
echo "emulate : " . $st->getAttribute(PDO::ATTR_EMULATE_PREPARES);
?>

output is "emulate : 1". I also tried the code :

$conn->setAttribute(PDO::ATTR_EMULATE_PREPARES,false);

but the output is still the same value "1". The output should be 0 if the value is false right? But why the output is 1? How to disable ATTR_EMULATE_PREPARES?

Author:zac1987,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/8636449/why-cannot-disable-pdoattr-emulate-prepares
yy