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

前端 未结 5 1932
天命终不由人
天命终不由人 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:24

    You can use mysqli_set_charset

    This is the preferred way to change the charset. Using mysqli_query() to set it (such as SET NAMES utf8) is not recommended.

    However, to set collation, you will still have to use the SET NAMES query.

提交回复
热议问题