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

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

      <tfoot id='e5hwH'></tfoot>
        <bdo id='e5hwH'></bdo><ul id='e5hwH'></ul>

      1. <legend id='e5hwH'><style id='e5hwH'><dir id='e5hwH'><q id='e5hwH'></q></dir></style></legend>

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

      2. 為什么不能序列化 PDO 對象?

        Why can#39;t a PDO object be serialized?(為什么不能序列化 PDO 對象?)
      3. <small id='RSyjd'></small><noframes id='RSyjd'>

        <tfoot id='RSyjd'></tfoot>

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

            <legend id='RSyjd'><style id='RSyjd'><dir id='RSyjd'><q id='RSyjd'></q></dir></style></legend>

                  <bdo id='RSyjd'></bdo><ul id='RSyjd'></ul>
                    <tbody id='RSyjd'></tbody>
                  本文介紹了為什么不能序列化 PDO 對象?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在制作一個多線程 CLI-PHP 應用程序,需要序列化 ??PDO 對象 以在線程內部的工作之間傳遞它,并使用魔術方法將其從睡眠線程中喚醒 __sleep()__wakeup().然而,PDOmysqli 擴展也不支持它.舊的 mysql_*() api 做到了這一點,但它已被棄用和刪除.

                  I am making a multi-threaded CLI-PHP application and need to serialize PDO object to pass it between work inside the thread, and wake it up from a sleeping thread using magic methods __sleep() and __wakeup(). However nor the PDO or mysqli extension supports it. The old mysql_*() api did this but it has been deprecated and removed.

                  <?php
                      // Application
                      $link = new PDO('mysql:host=localhost;port=3306;dbname=testdatabase', 'root', '');
                  
                      $obj = serialize($link);
                  

                  產生錯誤

                  PHP 致命錯誤:未捕獲的異常 'PDOException' 帶有消息 'You無法序列化或反序列化 PDO 實例W:workspaceSandboxapplication.php:5 堆棧跟蹤:

                  PHP Fatal error: Uncaught exception 'PDOException' with message 'You cannot ser ialize or unserialize PDO instances' in W:workspaceSandboxapplication.php:5 Stack trace:

                  #0 [內部函數]:PDO->__sleep()

                  #0 [internal function]: PDO->__sleep()

                  #1 W:workspaceSandboxapplication.php(5): 序列化(Object(PDO))

                  #1 W:workspaceSandboxapplication.php(5): serialize(Object(PDO))

                  #2 {main} 在第 5 行的 W:workspaceSandboxapplication.php 中拋出

                  #2 {main} thrown in W:workspaceSandboxapplication.php on line 5

                  推薦答案

                  PDO 對象包含無法以序列化格式表示的狀態.例如,PDO 對象包含一個到數據庫服務器的開放連接.

                  A PDO object contains state that cannot be represented in the serialization format. For example, the PDO object contains an open connection to a database server.

                  如果您嘗試反序列化一個序列化的 PDO 對象,__wakeup() 方法必須重新連接到數據庫服務器.這將要求身份驗證憑證以可讀方式存儲在序列化 PDO 對象中,這是安全禁忌.

                  If you were to try to deserialize a serialized PDO object, the __wakeup() method would have to reconnect to the database server. This would require that authentication credentials be stored in a readable manner in the serialized PDO object, which is a security no-no.

                  我很早以前就在研究 Zend Framework 的 Zend_Db 組件,因此我特意將 Zend_Db_Adapter 對象設計為不可序列化.Zend_Db_Table、Zend_Db_Table_Row 等的實例可以序列化,但在反序列化后不能活動",除非你為它分配了一個新連接的 Zend_Db_Adapter 實例.

                  I worked on the Zend Framework's Zend_Db component a long time ago, and I deliberately designed the Zend_Db_Adapter object to not be serializable for this reason. Instances of Zend_Db_Table, Zend_Db_Table_Row, etc. could be serializable, but could not be "live" after deserialization until you assigned it a freshly connected Zend_Db_Adapter instance.

                  此外,無法保證在您反序列化 PDO 對象時可以訪問數據庫服務器.目前尚不清楚這是否意味著反序列化將被視為失敗".

                  Also, there's no guarantee that the database server would be reachable at the time you deserialize the PDO object. It's unclear whether this means the deserialization would be considered "failed."

                  對序列化的相同限制適用于其他資源,例如套接字或文件句柄.

                  The same restrictions on serialization apply to other resources such as sockets or file handles.

                  另見 為什么不是每種類型的對象都可序列化?

                  這篇關于為什么不能序列化 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 找不到驅動程序)
                    <tbody id='G9f35'></tbody>
                  <tfoot id='G9f35'></tfoot>
                  • <bdo id='G9f35'></bdo><ul id='G9f35'></ul>

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

                            主站蜘蛛池模板: 免费观看一级特黄欧美大片 | 免费久久99精品国产婷婷六月 | 欧美成人免费电影 | 午夜影晥 | 中文欧美日韩 | 国产精品成人久久久久 | 综合欧美亚洲 | 亚洲欧美综合 | 天天草视频 | av永久| 欧美日韩视频网站 | 亚洲 欧美 在线 一区 | 欧美日产国产成人免费图片 | 亚洲午夜一区二区 | 国产精品美女www爽爽爽视频 | 国产不卡视频在线 | 亚洲在线高清 | 91在线视频播放 | 久久久夜夜夜 | 操到爽 | 蜜桃五月天 | 日韩精品一区二区三区中文在线 | 99免费精品视频 | 国产中文字幕av | 久久一区二区三区电影 | 97精品超碰一区二区三区 | 一区二区三区在线 | 国内av在线 | 日韩视频 中文字幕 | www国产精| 视频一区在线 | 日韩一级精品视频在线观看 | 美女爽到呻吟久久久久 | 久久久精品一区 | 91久久北条麻妃一区二区三区 | 日本一区二区在线视频 | 91精品国产乱码久久久久久 | 精品美女 | 一区精品国产欧美在线 | 午夜精品一区二区三区免费视频 | 久久久久久免费精品一区二区三区 |