In official documentation :
PDO :: MYSQL_ATTR_INIT_COMMAND (integer)
Command to execute when connecting to MySQL server. Will be run again when reconnecting.
Note that this constant can only be used in the driver_options array when
build a new database handler.
That is, it is a mysql
command that will run only once per connection as soon as you connect (or reconnect) to the server.
Example usage:
$db = new PDO('mysql:dbname=mydb;host=localhost;port=3306', $user, $pass,
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'")
);
The SET NAMES 'UTF8'
command will be run once whenever a new connection is started.