Some predefined constants of PDO_MYSQL. read some predefined constants of PDO_MYSQL. PDO_MYSQL is a mysql extension of PHPDataObjects (PDO) interface. Take a closer look at the php Manual. In fact, some interesting parameters are available, such as PDO: MYSQL_ATTR_INIT_COMMAND (integer)
PDO_MYSQL is a mysql extension of the PHP Data Objects (PDO) interface. Taking a closer look at the php manual, there are still some interesting parameters available, for example:
PDO: MYSQL_ATTR_INIT_COMMAND (integer)
Command to execute when connecting to the MySQL server. Will automatically be re-executed when reconnecting.
When I use PDO_MYSQL to connect to mysql, I can use this parameter to automatically execute some queries. The most common application scenario is to connect to mysql using the UTF-8 character set:
PLAIN TEXT
CODE:
$ Db = new PDO ("mysql: dbname = dbname", "user", "password", array (PDO: MYSQL_ATTR_INIT_COMMAND => "set names 'utf8 '"));
The above code will execute SQL immediately after connecting to mysql:
PLAIN TEXT
CODE:
Set names 'utf8 ';
Author: volcano