i'm using this PDO connection:
try{
$db=new PDO("
mysql:host=localhost;
dbname=...",
"dbu...",
"pass",
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET lc_time_names='de_DE'"));
}
catch(PDOException $e){die("Error!");}
Now i would like to add another init command:
array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET lc_time_names='de_DE'",
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
)
But it looks like that the utf8-one overwrites the first init command.
So i've tried this one but also without success:
array(
PDO::MYSQL_ATTR_INIT_COMMAND => array("SET lc_time_names='de_DE'","SET NAMES utf8")
)
Any idea how to send more than just one init command?
Thanks!
The correct syntax is:
array
(
PDO::MYSQL_ATTR_INIT_COMMAND
=>
"SET lc_time_names='de_DE',NAMES utf8"
)
So, NOT multiple arrays, but string with comma as separator and without repeating SET.
Edit: according with official documentation:
A SET statement can contain multiple variable assignments, separated by commas.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With