pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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

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

      2. PHP mysql_stmt::fetch() 導致 PHP 致命錯誤內存耗盡

        PHP mysql_stmt::fetch() gives PHP Fatal error memory exhausted(PHP mysql_stmt::fetch() 導致 PHP 致命錯誤內存耗盡)

            <tbody id='Zo5dX'></tbody>
          <legend id='Zo5dX'><style id='Zo5dX'><dir id='Zo5dX'><q id='Zo5dX'></q></dir></style></legend>

              <tfoot id='Zo5dX'></tfoot>
            1. <small id='Zo5dX'></small><noframes id='Zo5dX'>

                • <bdo id='Zo5dX'></bdo><ul id='Zo5dX'></ul>
                • <i id='Zo5dX'><tr id='Zo5dX'><dt id='Zo5dX'><q id='Zo5dX'><span id='Zo5dX'><b id='Zo5dX'><form id='Zo5dX'><ins id='Zo5dX'></ins><ul id='Zo5dX'></ul><sub id='Zo5dX'></sub></form><legend id='Zo5dX'></legend><bdo id='Zo5dX'><pre id='Zo5dX'><center id='Zo5dX'></center></pre></bdo></b><th id='Zo5dX'></th></span></q></dt></tr></i><div class="si0mio0" id='Zo5dX'><tfoot id='Zo5dX'></tfoot><dl id='Zo5dX'><fieldset id='Zo5dX'></fieldset></dl></div>
                • 本文介紹了PHP mysql_stmt::fetch() 導致 PHP 致命錯誤內存耗盡的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  CentOS 6.4 PHP 5.3.3 MySQL 5.1.69 x86_64

                  CentOS 6.4 PHP 5.3.3 MySQL 5.1.69 x86_64

                  mysql_stmt::fetch()
                  

                  當使用準備好的語句執行 fetch 時,PHP 產生錯誤:PHP Fatal error: Allowed memory size of 134217728 bytes expired (試圖分配 4294967296 字節).

                  When executing fetch using a prepared statement, PHP yields error: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967296 bytes).

                  當用于創建臨時表的 SELECT 語句中包含的變量未設置時,無論是否在調用存儲過程之前在環境中設置了該變量,都會發生這種情況.該變量必須在存儲過程中設置.當使用SELECT語句將臨時表中的數據返回給PHP,而PHP使用mysql_stmt::fetch()訪問數據時,PHP產生上述致命錯誤.

                  This occurs when a variable included in a SELECT statement used to create a temporary table is unset, whether or not the variable is otherwise set in the environment before the stored procedure is called. The variable must be set within the stored procedure. When a SELECT statement is used to return data in the temporary table to PHP, and PHP uses mysql_stmt::fetch() to access the data, PHP generates the above fatal error.

                  MySQL 代碼:

                  DELIMITER $$
                  CREATE PROCEDURE test_sp()
                  BEGIN
                  
                      # uncomment below line, and PHP call to mysqli_stmt::fetch() works
                      # SET @status = 1;
                  
                      # remove tmp table
                      DROP TABLE IF EXISTS tmp_table;
                      # CREATE TEMPORARY TABLE
                      CREATE TEMPORARY TABLE tmp_table
                          SELECT @status AS status;
                  
                      SELECT * FROM tmp_table;
                  
                  END $$
                  DELIMITER ;
                  

                  PHP 代碼:

                  // obtain MySQL login info
                  require_once(MYSQLOBJ);
                  
                  // initialize status
                  $status = "";
                  
                  
                  $db = new mysqli(
                      DB_HOST,
                      DB_USER,
                      DB_PASSWORD,
                      DB_NAME
                      );
                  
                  
                  $query = "CALL test_sp";
                  
                  $stmt = $db->prepare($query);
                  
                  $stmt->execute();
                  
                  $stmt->bind_result( $status );
                  
                  $stmt->store_result();
                  
                  $stmt->fetch(); // PHP FATAL ERROR OCCURS HERE
                  
                  $stmt->free_result();
                  
                  $db->close();
                  
                  print "<p>status = $status</p>
                  ";
                  

                  推薦答案

                  你會發現這@statusNULL 時發生> 或一個字符串.

                  You will find that this is occurring only when @status is NULL or a string.

                  問題是雙重的:

                  1. 與局部變量不同,MySQL 用戶變量支持非常有限的一組數據類型:

                  1. Unlike local variables, MySQL user variables support a very limited set of datatypes:

                  可以從一組有限的數據類型中為用戶變量分配一個值:整數、十進制、浮點、二進制或非二進制字符串,或者 NULL 值.

                  User variables can be assigned a value from a limited set of data types: integer, decimal, floating-point, binary or nonbinary string, or NULL value.

                  文檔沒有提到使用的實際數據類型分別是BIGINTDECIMAL(65,30)DOUBLELONGBLOBLONGTEXTLONGBLOB.關于最后一個,手冊至少做了解釋:

                  The documentation fails to mention that the actual datatypes used are respectively BIGINT, DECIMAL(65,30), DOUBLE, LONGBLOB, LONGTEXT and LONGBLOB. Regarding the last one, the manual does at least explain:

                  如果你引用一個沒有被初始化的變量,它的值是NULL,類型是字符串.

                  If you refer to a variable that has not been initialized, it has a value of NULL and a type of string.

                  前三種數據類型的存儲(即整數、十進制和浮點值)分別需要 8、30 和 8 個字節.其他數據類型(即字符串和 NULL 值)需要(最多)4 GB 的存儲空間.

                  Storage of the first three of these datatypes (i.e. for integer, decimal and floating-point values) require 8, 30 and 8 bytes respectively. The other datatypes (i.e. for string and NULL values) require (up to) 4 gigabytes of storage.

                  由于您使用的是 v5.4.0 之前的 PHP 版本,因此默認的 MySQL 驅動程序是 libmysql,在數據綁定時只有列類型元數據可從服務器獲得——因此 MySQLi 嘗試分配足夠的內存來保存每個可能的值(即使最終不需要完整的緩沖區);因此,NULL- 和字符串值的用戶變量(最大可能大小為 4GiB)導致 PHP 超出其默認內存限制(自 PHP v5.2.0 起為 128MiB).

                  Since you are using a version of PHP prior to v5.4.0, the default MySQL driver is libmysql, with which only column type metadata is available from the server upon data binding—so MySQLi attempts to allocate sufficient memory to hold every possible value (even if the full buffer is not ultimately required); thus NULL- and string-valued user variables, which have a maximum possible size of 4GiB, cause PHP to exceed its default memory limit (of 128MiB since PHP v5.2.0).

                  您的選擇包括:

                  • 覆蓋表定義中的列數據類型:

                  • Overriding the column datatype in the table definition:

                  DROP TEMPORARY TABLE IF EXISTS tmp_table;
                  CREATE TEMPORARY TABLE tmp_table (
                    status VARCHAR(2)
                  ) SELECT @status AS status;
                  

                • 顯式強制轉換用戶變量到更具體的數據類型:

                • Explicitly casting the user variable to a more specific datatype:

                  DROP TEMPORARY TABLE IF EXISTS tmp_table;
                  CREATE TEMPORARY TABLE tmp_table
                    SELECT CAST(@status AS CHAR(2)) AS status;
                  

                • 使用以顯式數據類型聲明的局部變量:

                • Using local variables, which are declared with an explicit datatype:

                  DECLARE status VARCHAR(2) DEFAULT @status;
                  DROP TEMPORARY TABLE IF EXISTS tmp_table;
                  CREATE TEMPORARY TABLE tmp_table
                    SELECT status;
                  

                • 通過調用 mysqli_stmt::store_result() before mysqli_stmt::bind_result(),這會導致結果集存儲在 libmysql 中(在 PHP 內存之外限制),然后 PHP 將僅在獲取記錄時分配保存記錄所需的實際內存:

                • Working around the issue by calling mysqli_stmt::store_result() before mysqli_stmt::bind_result(), which causes the resultset to be stored in libmysql (outside of PHP's memory limits) and then PHP will only allocate the actual memory required to hold the record upon fetching it:

                  $stmt->execute();
                  $stmt->store_result();
                  $stmt->bind_result( $status );
                  $stmt->fetch();
                  

                • 提高 PHP 的內存限制它可以適應 4GiB 緩沖區的分配(盡管人們應該意識到這樣做對硬件資源的影響)——例如,完全消除內存限制(盡管要意識到這樣做的潛在負面影響,例如來自真正的內存泄漏):

                • Raising PHP's memory limit so that it can accomodate the allocation of 4GiB buffers (although one should be aware of the implications on hardware resources from doing so)—for example, to remove the memory constraints entirely (although be aware of potential negative side-effects from doing this, e.g. from genuine memory leaks):

                  ini_set('memory_limit', '-1');
                  

                • 重新編譯PHP,配置為使用原生mysqlnd驅動(自 v5.3.0 起包含在 PHP 中,但在 PHP v5.4.0 之前未配置為默認值)而不是 libmysql:

                • Recompiling PHP, configured to use the native mysqlnd driver (included with PHP since v5.3.0, but not configured as the default until PHP v5.4.0) instead of libmysql:

                  ./configure --with-mysqli=mysqlnd
                  

                • 升級到 PHP v5.4.0 或更高版本,以便默認使用 mysqlnd.

                • Upgrading to PHP v5.4.0 or later so that mysqlnd is used by default.

                  這篇關于PHP mysql_stmt::fetch() 導致 PHP 致命錯誤內存耗盡的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                  Call to undefined function mysqli_result::num_rows()(調用未定義的函數 mysqli_result::num_rows())
                  PHP Prepared Statement Problems(PHP 準備好的語句問題)
                  mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個結果)
                  PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
                  How do I make sure that values from MySQL keep their type in PHP?(如何確保 MySQL 中的值在 PHP 中保持其類型?)
                  • <bdo id='jUPIk'></bdo><ul id='jUPIk'></ul>
                    <tfoot id='jUPIk'></tfoot>

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

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

                              <tbody id='jUPIk'></tbody>

                          • 主站蜘蛛池模板: 净气型药品柜-试剂柜-无管道净气型通风柜-苏州毕恩思 | 蓄电池回收,ups电池后备电源回收,铅酸蓄电池回收,机房电源回收-广州益夫铅酸电池回收公司 | 超声波清洗机_大型超声波清洗机_工业超声波清洗设备-洁盟清洗设备 | 陕西华春网络科技股份有限公司 | PC构件-PC预制构件-构件设计-建筑预制构件-PC构件厂-锦萧新材料科技(浙江)股份有限公司 | 体视显微镜_荧光生物显微镜_显微镜报价-微仪光电生命科学显微镜有限公司 | 27PR跨境电商导航 | 专注外贸跨境电商| 知名电动蝶阀,电动球阀,气动蝶阀,气动球阀生产厂家|价格透明-【固菲阀门官网】 | 断桥铝破碎机_发动机破碎机_杂铝破碎机厂家价格-皓星机械 | 成都竞价托管_抖音代运营_网站建设_成都SEM外包-成都智网创联网络科技有限公司 | 上海刑事律师|刑事辩护律师|专业刑事犯罪辩护律师免费咨询-[尤辰荣]金牌上海刑事律师团队 | 筒瓦厂家-仿古瓦-寺庙-古建琉璃瓦-宜兴市古典园林建筑陶瓷厂有限公司 | pbt头梳丝_牙刷丝_尼龙毛刷丝_PP塑料纤维合成毛丝定制厂_广州明旺 | 上海乾拓贸易有限公司-日本SMC电磁阀_德国FESTO电磁阀_德国FESTO气缸 | 不锈钢酒柜|恒温酒柜|酒柜定制|酒窖定制-上海啸瑞实业有限公司 | arch电源_SINPRO_开关电源_模块电源_医疗电源-东佑源 | 深圳天际源广告-形象堆头,企业文化墙,喷绘,门头招牌设计制作专家 | 上海办公室装修_上海店铺装修公司_厂房装潢设计_办公室装修 | 青岛侦探_青岛侦探事务所_青岛劝退小三_青岛婚外情取证-青岛王军侦探事务所 | 我爱古诗词_古诗词名句赏析学习平台 | 自动气象站_气象站监测设备_全自动气象站设备_雨量监测站-山东风途物联网 | 手板-手板模型-手板厂-手板加工-生产厂家,[东莞创域模型] | 无锡装修装潢公司,口碑好的装饰装修公司-无锡索美装饰设计工程有限公司 | 流程管理|流程管理软件|企业流程管理|微宏科技-AlphaFlow_流程管理系统软件服务商 | 步进驱动器「一体化」步进电机品牌厂家-一体式步进驱动 | 洗地机_全自动洗地机_手推式洗地机【上海滢皓环保】 | SMC-SMC电磁阀-日本SMC气缸-SMC气动元件展示网 | 玻纤土工格栅_钢塑格栅_PP焊接_单双向塑料土工格栅_复合防裂布厂家_山东大庚工程材料科技有限公司 | 厦门网站建设_厦门网站设计_小程序开发_网站制作公司【麦格科技】 | 岛津二手液相色谱仪,岛津10A液相,安捷伦二手液相,安捷伦1100液相-杭州森尼欧科学仪器有限公司 | 求是网 - 思想建党 理论强党 | 国产离子色谱仪,红外分光测油仪,自动烟尘烟气测试仪-青岛埃仑通用科技有限公司 | 西安展台设计搭建_西安活动策划公司_西安会议会场布置_西安展厅设计西安旭阳展览展示 | 洗瓶机厂家-酒瓶玻璃瓶冲瓶机-瓶子烘干机-封口旋盖压盖打塞机_青州惠联灌装机械 | 河南中整光饰机械有限公司-抛光机,去毛刺抛光机,精密镜面抛光机,全自动抛光机械设备 | 百度关键词优化_网站优化_SEO价格 - 云无限好排名 | 印刷人才网 印刷、包装、造纸,中国80%的印刷企业人才招聘选印刷人才网! | 电动球阀_不锈钢电动球阀_电动三通球阀_电动调节球阀_上海湖泉阀门有限公司 | 石磨面粉机|石磨面粉机械|石磨面粉机组|石磨面粉成套设备-河南成立粮油机械有限公司 | 在线钠离子分析仪-硅酸根离子浓度测定仪-油液水分测定仪价格-北京时代新维测控设备有限公司 | 杭州中央空调维修_冷却塔/新风机柜/热水器/锅炉除垢清洗_除垢剂_风机盘管_冷凝器清洗-杭州亿诺能源有限公司 |