<legend id='DhsTb'><style id='DhsTb'><dir id='DhsTb'><q id='DhsTb'></q></dir></style></legend>
      <bdo id='DhsTb'></bdo><ul id='DhsTb'></ul>
  • <small id='DhsTb'></small><noframes id='DhsTb'>

    <tfoot id='DhsTb'></tfoot>

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

        是否可以回退 PDO 结果?

        时间:2023-11-30
        <i id='6pOzJ'><tr id='6pOzJ'><dt id='6pOzJ'><q id='6pOzJ'><span id='6pOzJ'><b id='6pOzJ'><form id='6pOzJ'><ins id='6pOzJ'></ins><ul id='6pOzJ'></ul><sub id='6pOzJ'></sub></form><legend id='6pOzJ'></legend><bdo id='6pOzJ'><pre id='6pOzJ'><center id='6pOzJ'></center></pre></bdo></b><th id='6pOzJ'></th></span></q></dt></tr></i><div id='6pOzJ'><tfoot id='6pOzJ'></tfoot><dl id='6pOzJ'><fieldset id='6pOzJ'></fieldset></dl></div>
        • <tfoot id='6pOzJ'></tfoot>
            <bdo id='6pOzJ'></bdo><ul id='6pOzJ'></ul>
                <legend id='6pOzJ'><style id='6pOzJ'><dir id='6pOzJ'><q id='6pOzJ'></q></dir></style></legend>

                    <tbody id='6pOzJ'></tbody>

                  <small id='6pOzJ'></small><noframes id='6pOzJ'>

                  本文介绍了是否可以回退 PDO 结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试为 PDO 语句的结果编写一个迭代器,但我找不到任何方法可以倒回到第一行.我想避免调用 fetchAll 并存储所有结果数据的开销.

                  I'm trying to write an iterator for results from a PDO statement but I can't find any way of rewinding to the first row. I would like to avoid the overhead of calling fetchAll and storing all the result data.

                  // first loop works fine
                  foreach($statement as $result) {
                      // do something with result
                  }
                  
                  // but subsequent loops don't
                  foreach($statement as $result) {
                      // never called 
                  }
                  

                  有没有办法重置语句或寻找第一行?

                  Is there some way of reseting the statement or seeking the first row?

                  推荐答案

                  我很确定这是依赖于数据库的.正因为如此,这是你应该尽量避免的事情.但是,我认为您可以通过启用 缓冲查询 来实现您想要的.如果这不起作用,您始终可以使用 fetchAll.这两种解决方案都会影响您的应用程序性能,因此如果结果集很大,请三思而后行.

                  I'm pretty sure this is database dependent. Because of that, it is something you should try to avoid. However, I think you can achieve what you want by enabling buffered queries. If that doesn't work, you can always pull the result into an array with fetchAll. Both solutions have implications for your applications performance, so think twice about it, if the resultsets are large.

                  这篇关于是否可以回退 PDO 结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:可迭代对象和数组类型提示? 下一篇:PHP - 使用迭代器的原因?

                  相关文章

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

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

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

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