php mysql SET NAMES 'utf8' COLLATE 'utf8_unicode_ci' doesn't work with mysqli

前端 未结 5 1943
天命终不由人
天命终不由人 2020-12-18 07:04

I am migrating my site into php mysqli from php mysql_* methods.

I had following code that did the job:

mysql_query(\"SET NAMES \'utf8\' COLLA

5条回答
  •  醉话见心
    2020-12-18 07:15

    It is not recommended to use mysqli query in order to set names but rather mysqli::set_charset

    $mysqli = new mysqli("localhost", "root", "", "test");
    $mysqli->set_charset("utf8");
    

提交回复
热议问题