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

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

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

      1. PHP7 的 PDO ext 是否将整个结果集读入内存?

        Does PHP7#39;s PDO ext read the entire result set into memory?(PHP7 的 PDO ext 是否将整个结果集读入内存?)

      2. <legend id='hp2mp'><style id='hp2mp'><dir id='hp2mp'><q id='hp2mp'></q></dir></style></legend>

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

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

                  本文介绍了PHP7 的 PDO ext 是否将整个结果集读入内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  自从我升级到 PHP7 后,我注意到一些 SQL 语句不再起作用,而是内存不足.

                  I have noticed since I upgraded to PHP7 that some SQL statements no longer work and instead run out of memory.

                  我有这个代码:

                  $query = Yii::$app->db->createCommand('select * from tbl_title')->query();
                  while ($row = $reader->read()) {
                      var_dump($row);
                      exit();
                  }
                  

                  而 Yii2 的数据库抽象只是 PDO 之上的一个非常薄的层,并没有做任何额外的事情.query() 除了在日志文件(Yii2 的)中添加一行用于分析和 reader->read() 只调用 PDO 流的 fetch() 函数.

                  And Yii2's database abstraction is just an extremely thin layer over PDO's and does not do anything extra. query() does nothing extra except add a line to a log file (Yii2's) for profiling and reader->read() just calls the PDO stream's fetch() function.

                  但是引用我的表的大小(使用的空间)时内存不足,即尝试分配 385 MB 的进程内存:

                  But it runs out of memory quoting the size (space used) of my table, i.e. trying to allocate 385 MB of process memory:

                  允许的内存大小为 134217728 字节耗尽(尝试分配 385883840 字节)

                  Allowed memory size of 134217728 bytes exhausted (tried to allocate 385883840 bytes)

                  作为扳手,如果我使用的查询的结果集完全符合 PHP 进程的 128 MB 限制.

                  As a spanner, if I use a query whose result set fits entirely in the 128 MB limit of the PHP process works.

                  那么,PHP7 是否发生了变化,我可以将其改回来吗?

                  So, has PHP7 changed and can I change it back?

                  推荐答案

                  它与 PHP7 没有直接关系.该问题是由于新的 mysqlnd 驱动程序造成的,因此即使使用 PHP 5.x,您也会遇到同样的问题.这实际上是一个错误修正,因为甚至在内存仍然分配之前,但它并不计入 memory_limit.

                  It is not directly PHP7-related. The issue is due to new mysqlnd driver, so you can experience the the same problem even with PHP 5.x as well. It is actually a bugfix, because even before the memory was still allocated, but it didn't count towards memory_limit.

                  为了避免内存问题,您必须对大型结果集使用无缓冲查询.

                  To avoid a memory issue you have to use unbuffered queries for the large resultsets.

                  因此,对于需要大型数据集的查询,请像这样设置正确的设置:

                  So, for the query that is expecting a large dataset, set the proper setting like this:

                  $pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
                  

                  为了进一步阅读,我在我的 PDO 教程中有一个不错的解释,感谢Nikic,他的批评反馈非常宝贵.

                  For the further reading, I've got a decent explanation in my PDO tutorial, thanks to Nikic, whose critical feedback was invaluable.

                  这篇关于PHP7 的 PDO ext 是否将整个结果集读入内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Is Joomla 2.5 much faster than Joomla 1.5 Querywise(Joomla 2.5 比 Joomla 1.5 Querywise 快得多吗)
                  How to share Joomla login session from one joomla website to one ASP.Net MVC website(如何将 Joomla 登录会话从一个 joomla 网站共享到一个 ASP.Net MVC 网站)
                  htaccess redirect root to subdirectory but allow index.php in root AND query strings to function(htaccess 将根重定向到子目录,但允许根和查询字符串中的 index.php 起作用)
                  Joomla include database functions(Joomla 包含数据库功能)
                  nl2br() not working when displaying SQL results(显示 SQL 结果时 nl2br() 不起作用)
                  Joomla 2.5 JFactory::getSession(); seems to be caching in firefox(Joomla 2.5 JFactory::getSession();似乎在 Firefox 中缓存)

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

                  • <tfoot id='NEZcW'></tfoot>

                          <bdo id='NEZcW'></bdo><ul id='NEZcW'></ul>

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