如何设置整理和字符UTF8 - Mysql PDO

时间:2017-05-28 02:07:39

标签: mysql pdo utf-8

这是我的PDO课程

class Database{

    public $isConn;
    protected $datab;

//connect to db
public function __construct($username = "root" , $password = "" , $host = "localhost" , $dbname = "job" , $options =[ ]){
    $this->isConn = TRUE;
    try{

        $this->datab = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8",$username , $password ,$options);
        $this->datab->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
        $this->datab->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);


    } catch ( PDOException $e ){

        throw new Exception($e->getMessage());


    }`enter code here`


}

任何人请帮助,我的数据库值是日语然后我想输出日语单词。我如何更改此代码?

0 个答案:

没有答案