久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <legend id='zgXVK'><style id='zgXVK'><dir id='zgXVK'><q id='zgXVK'></q></dir></style></legend>
      <bdo id='zgXVK'></bdo><ul id='zgXVK'></ul>

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

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

    1. 如何在沒有 SET NAMES 的情況下使用 PDO 指定排序規

      How to specify collation with PDO without SET NAMES?(如何在沒有 SET NAMES 的情況下使用 PDO 指定排序規則?)
      <i id='g9eTj'><tr id='g9eTj'><dt id='g9eTj'><q id='g9eTj'><span id='g9eTj'><b id='g9eTj'><form id='g9eTj'><ins id='g9eTj'></ins><ul id='g9eTj'></ul><sub id='g9eTj'></sub></form><legend id='g9eTj'></legend><bdo id='g9eTj'><pre id='g9eTj'><center id='g9eTj'></center></pre></bdo></b><th id='g9eTj'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='g9eTj'><tfoot id='g9eTj'></tfoot><dl id='g9eTj'><fieldset id='g9eTj'></fieldset></dl></div>
        <bdo id='g9eTj'></bdo><ul id='g9eTj'></ul>
        • <small id='g9eTj'></small><noframes id='g9eTj'>

              <tbody id='g9eTj'></tbody>

              <tfoot id='g9eTj'></tfoot>
              • <legend id='g9eTj'><style id='g9eTj'><dir id='g9eTj'><q id='g9eTj'></q></dir></style></legend>
                本文介紹了如何在沒有 SET NAMES 的情況下使用 PDO 指定排序規則?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我們可以在初始化 PDO 時顯式設置字符集為 utf8,只需在 dsn 字符串中添加charset=utf8"即可.但是如何在使用 PDO 時顯式指定 MySQL 連接中使用的排序規則?

                We can explicitly set the char set to utf8 when initializing PDO, just add "charset=utf8" to the dsn string. But how does one explicitly specify the collation used in MySQL connection when using PDO?

                我不想使用額外的查詢來執行此操作:

                I don't want to use an additional query to do this:

                SET NAMES utf8 COLLATE utf8_unicode_ci;
                

                有沒有什么辦法不用SET NAMES"呢?或者,如果我不指定排序規則會有什么問題嗎?

                Is there any way without having to resort to "SET NAMES"? Or, would there be any problem if I don't specify a collation?

                推薦答案

                這里是二合一的答案.

                您可以在 DSN 或 MYSQL_ATTR_INIT_COMMAND(連接選項)中設置它.

                You can set this in the DSN or as MYSQL_ATTR_INIT_COMMAND (connection options).

                DSN 更好,我認為.

                DSN is better, i think.

                $connect = new PDO(
                  "mysql:host=$host;dbname=$db;charset=utf8", 
                  $user, 
                  $pass, 
                  array(
                    PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
                  )
                ); 
                

                如果您指定 UTF-8,您將使用 utf8_general_ci 的默認排序規則,除非您的數據庫表或字段使用不同的內容.

                If you specify UTF-8 you are working with the default collation of utf8_general_ci, unless your db table or field uses something different.

                如果您希望整個服務器使用此默認排序規則進行響應,請使用配置指令:

                If you want the whole server to respond with this default collation then use configuration directives:

                collation_server=utf8_unicode_ci 
                character_set_server=utf8
                

                因此您不必每次都在連接時指定它.

                So you don't have to specify it on connection everytime.

                排序規則會影響字符的排序,并在數據庫中的表和字段上設置.查詢表時,會遵守這些設置.確保它們已設置.使用 UTF-8 名稱和數據庫中設置的排序規則.

                The collations affect the sorting of chars and is set on the table and fields in your database. These settings are respected, when querying the table. Make sure they are set. Use UTF-8 names with the collation set in your db.

                您的評論:

                人們應該知道字符集和排序規則是兩件不同的事情."

                "People should know char set and collation are 2 different things."

                讓我們引用 MySQL 手冊來證明這個:

                Let's Quote from the MySQL Manual to proof this:

                一個 SET NAMES 'charset_name' 語句相當于這三個聲明:

                A SET NAMES 'charset_name' statement is equivalent to these three statements:

                SET character_set_client = charset_name;
                SET character_set_results = charset_name;
                SET character_set_connection = charset_name;
                

                character_set_connection 設置為 charset_name 也會隱式地將 collat??ion_connection 設置為默認排序規則charset_name.

                Setting character_set_connection to charset_name also implicitly sets collation_connection to the default collation for charset_name.

                我的回答:它是隱式工作的,除非您的表顯式更改它.

                來自評論的問題:

                如何確保我不會把事情搞砸,因為我的桌子不是默認排序規則utf8_general_ci?

                How to make sure I don't mess things up as my tables are not the default collation utf8_general_ci?

                示例:列排序規則覆蓋表排序規則

                CREATE TABLE t1
                (
                    col1 CHAR(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci
                ) CHARACTER SET latin1 COLLATE latin1_bin;
                

                如果在列上同時指定了 CHARACTER SET X 和 COLLATE Y,則使用字符集 X 和排序規則 Y.該列具有表列中指定的字符集 utf8 和排序規則 utf8_unicode_ci,而該表在 latin1 + latin1_bin 中.

                If both CHARACTER SET X and COLLATE Y are specified on a column, character set X and collation Y are used. The column has character set utf8 and collation utf8_unicode_ci as specified in the table column, while the table is in latin1 + latin1_bin.

                示例:通常使用表格整理

                如果未在列/字段上明確指定排序規則,則使用表排序規則:

                If collation is not explicitly specified on a column/Field, then the table collation is used:

                CREATE TABLE t1
                (
                    col1 CHAR(10)
                ) CHARACTER SET latin1 COLLATE latin1_bin;
                

                col1 具有排序規則 latin1_bin.

                col1 has collation latin1_bin.

                如果您想要 utf8_unicode_ci 整理,請將其設置為您的一般表格或列/字段.

                If you want utf8_unicode_ci collation, set it to your tables in general or to the columns/fields.

                這篇關于如何在沒有 SET NAMES 的情況下使用 PDO 指定排序規則?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                PHP PDO ODBC connection(PHP PDO ODBC 連接)
                Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)

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

                  1. <small id='vOiX3'></small><noframes id='vOiX3'>

                        <bdo id='vOiX3'></bdo><ul id='vOiX3'></ul>
                      • <legend id='vOiX3'><style id='vOiX3'><dir id='vOiX3'><q id='vOiX3'></q></dir></style></legend>

                          主站蜘蛛池模板: 一级免费a | 国产h在线| 精品福利视频一区二区三区 | 国产视频不卡一区 | 黑人巨大精品欧美一区二区免费 | av在线免费观看网址 | 久草在线在线精品观看 | 日韩视频观看 | 日日操天天射 | 中文字幕福利视频 | 久久久91精品国产一区二区三区 | 亚洲国产一区二区三区, | 久久成人精品视频 | 欧美成人a∨高清免费观看 色999日韩 | 国产精品一区二区av | 成人午夜免费网站 | 午夜色婷婷 | 成人精品一区亚洲午夜久久久 | 婷婷综合网 | 求毛片| 一区二区三区四区不卡视频 | 免费同性女女aaa免费网站 | 精品伊人久久 | 久久久久久亚洲精品 | 欧美精品一区二区三区在线播放 | 欧美午夜视频 | 国产一区二区三区在线看 | 欧美日韩综合精品 | 亚洲精品乱码久久久久久按摩观 | 国产福利视频 | 香蕉大人久久国产成人av | av日韩精品 | 午夜免费电影院 | 粉嫩高清一区二区三区 | 国产精品免费看 | 亚洲精品视频在线看 | 日本一区二区三区在线观看 | 成人免费在线观看视频 | 国产精品国产精品国产专区不蜜 | 国产99小视频 | 国产精品免费一区二区三区 |