How to specify collation with PDO without SET NAMES?

前端 未结 3 1277
我寻月下人不归
我寻月下人不归 2020-12-10 07:37

We can explicitly set the char set to utf8 when initializing PDO, just add \"charset=utf8\" to the dsn string. But how does one explicitly specify the collation

3条回答
  •  感情败类
    2020-12-10 08:12

    Use this ---Done----

    $pdo = new PDO('mysql:host=localhost;dbname=vocabulary;charset=utf-8', "root", "", array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
    

    and in HTML page use

    
    

提交回复
热议问题