• <tfoot id='SOyA9'></tfoot>
      <bdo id='SOyA9'></bdo><ul id='SOyA9'></ul>

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

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

        使用准备好的语句编写查询的分页结果集,

        时间:2023-07-29
        • <i id='H7Nj0'><tr id='H7Nj0'><dt id='H7Nj0'><q id='H7Nj0'><span id='H7Nj0'><b id='H7Nj0'><form id='H7Nj0'><ins id='H7Nj0'></ins><ul id='H7Nj0'></ul><sub id='H7Nj0'></sub></form><legend id='H7Nj0'></legend><bdo id='H7Nj0'><pre id='H7Nj0'><center id='H7Nj0'></center></pre></bdo></b><th id='H7Nj0'></th></span></q></dt></tr></i><div id='H7Nj0'><tfoot id='H7Nj0'></tfoot><dl id='H7Nj0'><fieldset id='H7Nj0'></fieldset></dl></div>
            <tbody id='H7Nj0'></tbody>
            <tfoot id='H7Nj0'></tfoot>

              • <legend id='H7Nj0'><style id='H7Nj0'><dir id='H7Nj0'><q id='H7Nj0'></q></dir></style></legend>

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

                • <bdo id='H7Nj0'></bdo><ul id='H7Nj0'></ul>
                • 本文介绍了使用准备好的语句编写查询的分页结果集,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  在以传统方式进行查询之前,我一直在使用分页类,但现在我已经开始使用准备好的语句进行查询,通过 $stmt->fetch() 语句,我不知道如何现在分页.我一直在环顾四周并检查 stackoverflow 文献,似乎有一些现成的解决方案,一些命令或一些:sort-> 东西.

                  I have been using paginating classes when I did before the query the traditional way, but now that I have come to do the queries using prepared statements, via the $stmt->fetch() statement, I don't know how to paginate now. I have been looking around and checking the stackoverflow literature and it seems that there is some kind of ready solution for it, some commands or some : sort-> stuff.

                  你如何对这个循环中的内容进行分页?准备好的语句世界"中是否有一些命令?任何显示的链接、页面或网络?

                  How do you paginate what comes out of this loop? Are there some commands within the "world of prepared statements"? any link, page or web where that is shown?

                  while( $stmt->fetch() )
                      {
                          printf("%s%s%s%s", $Email, $Webpage, $Telephone, $Mobile);
                      }
                  

                  推荐答案

                  方法一:get_result():

                  *注意:此方法仅适用于 PHP >= 5.3,具有 mysqlnd 本机驱动程序.

                  Method 1: get_result():

                  *Note: This method only works with PHP >= 5.3, having the mysqlnd native driver.

                  假设这是使用 MySQLi 完成的,并且您已通过 bind_result() 将这些变量绑定为结果变量,我将改为使用 get_result() 将其传输到 MySQLi 结果资源中,并将行作为数组提取到包含所有行的数组.然后使用通常用于数组数据的任何分页方法或插件:

                  Assuming this was done with MySQLi and you have bound these variables as result vars via bind_result(), I would instead use get_result() to transfer it into a MySQLi result resource, and fetch the rows as arrays onto an array containing all rows. Then use any pagination method or plugin you would normally use on array data:

                  // Don't use bind_result()...
                  // execute your statement
                  $stmt->execute();
                  // Get result set into a MySQLi result resource
                  $result = $stmt->get_result();
                  
                  // array to hold all results
                  $rowset = array();
                  // And fetch with a while loop
                  while ($row = $result->fetch_assoc()) {
                    $rowset[] = $row;
                  }
                  

                  var_dump($rowset);

                      var_dump($rowset);

                  现在将 $rowset 用作二维数组,您可以使用它使用任何对常规数组进行操作的分页方法.

                  Now use $rowset as a 2D array, with which you can use any pagination method that operates on regular arrays.

                  如果您没有 mysqlnd 本机驱动程序(因此无法使用 get_result(),请继续使用 bind_result(),但将所有这些附加到数组中:

                  If you don't have the mysqlnd native driver (and hence cannot use get_result(), continue using bind_result() but append all of those onto an array:

                  // array to hold all rows
                  $rowset = array();
                  
                  // All results bound to output vars
                  while ($stmt->fetch()) {
                    // Append an array containing your result vars onto the rowset array
                    $rowset[] = array(
                      'email' => $Email,
                      'webpage' => $Webpage,
                      'telephone' => $Telephone,
                      'moblile' => $Mobile
                    );
                  }
                  var_dump($rowset);
                  

                  这篇关于使用准备好的语句编写查询的分页结果集,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 mysqli 中存储和迭代查询结果 下一篇:如何正确使用 PHP 将 MySQL 对象编码为 JSON?

                  相关文章

                  最新文章

                  <tfoot id='tdWEz'></tfoot>

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

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