• <tfoot id='a2uJk'></tfoot>
    <legend id='a2uJk'><style id='a2uJk'><dir id='a2uJk'><q id='a2uJk'></q></dir></style></legend>
    <i id='a2uJk'><tr id='a2uJk'><dt id='a2uJk'><q id='a2uJk'><span id='a2uJk'><b id='a2uJk'><form id='a2uJk'><ins id='a2uJk'></ins><ul id='a2uJk'></ul><sub id='a2uJk'></sub></form><legend id='a2uJk'></legend><bdo id='a2uJk'><pre id='a2uJk'><center id='a2uJk'></center></pre></bdo></b><th id='a2uJk'></th></span></q></dt></tr></i><div id='a2uJk'><tfoot id='a2uJk'></tfoot><dl id='a2uJk'><fieldset id='a2uJk'></fieldset></dl></div>

  • <small id='a2uJk'></small><noframes id='a2uJk'>

      • <bdo id='a2uJk'></bdo><ul id='a2uJk'></ul>

        如何在 PHP PgSQL 数据库的 PDO 类构造函数中设置

        时间:2023-10-05
      1. <legend id='o7BAC'><style id='o7BAC'><dir id='o7BAC'><q id='o7BAC'></q></dir></style></legend>
            • <bdo id='o7BAC'></bdo><ul id='o7BAC'></ul>

              <small id='o7BAC'></small><noframes id='o7BAC'>

            • <tfoot id='o7BAC'></tfoot>
                <i id='o7BAC'><tr id='o7BAC'><dt id='o7BAC'><q id='o7BAC'><span id='o7BAC'><b id='o7BAC'><form id='o7BAC'><ins id='o7BAC'></ins><ul id='o7BAC'></ul><sub id='o7BAC'></sub></form><legend id='o7BAC'></legend><bdo id='o7BAC'><pre id='o7BAC'><center id='o7BAC'></center></pre></bdo></b><th id='o7BAC'></th></span></q></dt></tr></i><div id='o7BAC'><tfoot id='o7BAC'></tfoot><dl id='o7BAC'><fieldset id='o7BAC'></fieldset></dl></div>
                  <tbody id='o7BAC'></tbody>

                  本文介绍了如何在 PHP PgSQL 数据库的 PDO 类构造函数中设置 UTF-8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想为我的 PDO 对象设置 UTF8.此类与 MySQL 一起正常工作.我找不到 PgSQL 的 array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES UTF8") 类似物,而且我无法使用西里尔符号.

                  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") for PgSQL and I can't work with cyrillic symbols.

                  class oop{
                  private $host="localhost";
                      private $user="xxxx";
                      private $db="xxxx";
                      private $pass="111111";
                      private $conn;
                  
                  public function __construct(){
                  
                      $this->conn = new PDO("pgsql:host=".$this->host.";dbname=".$this->db,$this->user,$this->pass,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES UTF8") );
                  
                  }
                  

                  推荐答案

                  从我在 这个页面,你可以使用以下两个命令之一:

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

                  1. 将 CLIENT_ENCODING 设置为值";
                  2. SET NAMES 'value';

                  其中值 = UTF8.尝试使用:

                  where value = UTF8. Try using:

                  SET CLIENT_ENCODING TO 'UTF8';
                  

                  SET NAMES 'UTF8';
                  

                  这篇关于如何在 PHP PgSQL 数据库的 PDO 类构造函数中设置 UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将 PHP while 循环转换为使用 PDO 下一篇:如何在没有 SET NAMES 的情况下使用 PDO 指定排序规

                  相关文章

                  最新文章

                  1. <i id='VGiU9'><tr id='VGiU9'><dt id='VGiU9'><q id='VGiU9'><span id='VGiU9'><b id='VGiU9'><form id='VGiU9'><ins id='VGiU9'></ins><ul id='VGiU9'></ul><sub id='VGiU9'></sub></form><legend id='VGiU9'></legend><bdo id='VGiU9'><pre id='VGiU9'><center id='VGiU9'></center></pre></bdo></b><th id='VGiU9'></th></span></q></dt></tr></i><div id='VGiU9'><tfoot id='VGiU9'></tfoot><dl id='VGiU9'><fieldset id='VGiU9'></fieldset></dl></div>

                    <small id='VGiU9'></small><noframes id='VGiU9'>

                      <tfoot id='VGiU9'></tfoot>
                    1. <legend id='VGiU9'><style id='VGiU9'><dir id='VGiU9'><q id='VGiU9'></q></dir></style></legend>
                        <bdo id='VGiU9'></bdo><ul id='VGiU9'></ul>