How set UTF-8 in PDO class constructor for PHP PgSQL database

后端 未结 3 615
栀梦
栀梦 2020-12-09 20:31

I want to set UTF8 for my PDO object. This class works correctly with MySQL. I can\'t find an analog of array(PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES UTF8\")

3条回答
  •  一生所求
    2020-12-09 21:28

    From what I see in section 21.2.3 on this page, you can use one of the following two commands:

    1. SET CLIENT_ENCODING TO 'value';
    2. SET NAMES 'value';

    where value = UTF8. Try using:

    SET CLIENT_ENCODING TO 'UTF8';
    

    or

    SET NAMES 'UTF8';
    

提交回复
热议问题