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

        • <bdo id='NIQmQ'></bdo><ul id='NIQmQ'></ul>
        <tfoot id='NIQmQ'></tfoot>
      1. <small id='NIQmQ'></small><noframes id='NIQmQ'>

        此结果是仅向前的结果集,不支持向前移动后调

        时间:2023-10-02
            <legend id='58rvH'><style id='58rvH'><dir id='58rvH'><q id='58rvH'></q></dir></style></legend>
            • <bdo id='58rvH'></bdo><ul id='58rvH'></ul>

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

              1. <tfoot id='58rvH'></tfoot>
              2. <small id='58rvH'></small><noframes id='58rvH'>

                1. 本文介绍了此结果是仅向前的结果集,不支持向前移动后调用 rewind() - Zend的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  在 Zend 应用程序中,我使用 ZendDbTableGatewayZendDbSql 从 MySQL 数据库中检索数据数据,如下所示.

                  In Zend app, I use ZendDbTableGateway and ZendDbSql to retrieve data data from MySQL database as below.

                  模型 -

                  public function getCandidateEduQualifications($id)
                  {
                      $id  = (int) $id;
                  
                      $rowset = $this->tableGateway->select(function (SqlSelect $select) use ($id)
                      {
                          $select->where
                              ->AND->NEST->equalTo('candidate_id', $id)
                              ->AND->equalTo('qualification_category', 'Educational');
                      });
                  
                      return $rowset;
                  }
                  

                  查看 -

                  我只是在视图中迭代 $rowset 和 echo.但是当尝试回显两次或更多次时它会出错.单次迭代有效.

                  I just iterate $rowset and echo in view. But it gives error when try to echo two or more times. Single iteration works.

                  这个结果是一个只向前的结果集,在调用rewind()之后不支持前进

                  This result is a forward only result set, calling rewind() after moving forward is not supported

                  我可以通过将其加载到视图中的另一个数组来解决它.但这是最好的方法吗?有没有其他办法可以解决这个问题?

                  I can solve it by loading it to another array in view. But is it the best way ? Is there any other way to handle this ?

                  $records = array();
                  foreach ($edu_qualifications as $result) {
                      $records[] = $result;
                  }
                  

                  编辑 -

                  $resultSet->buffer(); 解决了这个问题.

                  推荐答案

                  您收到此 Exception 因为这是预期的行为.Zend 使用 PDO 来获取它的 ZendDbResultSetZendDbTableGatewayTableGateway 返回的结果集.PDO 结果集默认使用只进游标,这意味着您只能循环一次.

                  You receive this Exception because this is expected behavior. Zend uses PDO to obtain its ZendDbResultSetResultset which is returned by ZendDbTableGatewayTableGateway. PDO result sets use a forward-only cursor by default, meaning you can only loop through the set once.

                  有关游标的更多信息,请查看维基百科和这个 文章.

                  For more information about cursors check Wikipedia and this article.

                  作为 ZendDbResultSetResultset 实现 PHP Iterator 您可以使用 ZendDbResultSetResultset:toArray() 方法或使用 iterator_to_array() 函数.在潜在的大型数据集上使用此函数时请务必小心!关于游标的最好的事情之一正是它们避免一次性引入所有内容,以防数据集太大,因此有时您不想一次将其全部放入数组中.

                  As the ZendDbResultSetResultset implements the PHP Iterator you can extract an array of the set using the ZendDbResultSetResultset:toArray() method or using the iterator_to_array() function. Do be careful though about using this function on potentially large datasets! One of the best things about cursors is precisely that they avoid bringing in everything in one go, in case the data set is too large, so there are times when you won't want to put it all into an array at once.

                  这篇关于此结果是仅向前的结果集,不支持向前移动后调用 rewind() - Zend的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:格式化 MySQL 查询的结果,就好像它是从控制台运 下一篇:将外部脚本与 Zend Framework 集成

                  相关文章

                  最新文章

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

                  3. <small id='1bkr7'></small><noframes id='1bkr7'>

                        <bdo id='1bkr7'></bdo><ul id='1bkr7'></ul>