久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

    1. <tfoot id='LsxIA'></tfoot>
      • <bdo id='LsxIA'></bdo><ul id='LsxIA'></ul>

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

        相當于 mysql_num_rows 或 mssql_num_rows 的 PDO

        PDO equivalent of mysql_num_rows or mssql_num_rows(相當于 mysql_num_rows 或 mssql_num_rows 的 PDO)
          <tbody id='qQANx'></tbody>

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

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

              <i id='qQANx'><tr id='qQANx'><dt id='qQANx'><q id='qQANx'><span id='qQANx'><b id='qQANx'><form id='qQANx'><ins id='qQANx'></ins><ul id='qQANx'></ul><sub id='qQANx'></sub></form><legend id='qQANx'></legend><bdo id='qQANx'><pre id='qQANx'><center id='qQANx'></center></pre></bdo></b><th id='qQANx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='qQANx'><tfoot id='qQANx'></tfoot><dl id='qQANx'><fieldset id='qQANx'></fieldset></dl></div>
              <tfoot id='qQANx'></tfoot>
              <legend id='qQANx'><style id='qQANx'><dir id='qQANx'><q id='qQANx'></q></dir></style></legend>
                1. 本文介紹了相當于 mysql_num_rows 或 mssql_num_rows 的 PDO的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我知道以前有人問過這個問題,但似乎解決方案是針對所提出的問題的.

                  I know this question has been asked before but it seems like the solutions have been specific to the problem presented.

                  我有一個包含數百個使用 mssql_num_rows 實例的代碼庫.

                  I have a codebase with hundreds of instances where mssql_num_rows is used.

                  代碼示例:

                  $db->execute($sql);
                  
                  if ($db->getRowsAffected() > 0) {
                      $total = $db->fetch();
                  

                  在數據庫類中:

                  $this->rowsaffected = mssql_num_rows($this->query_result);
                  

                  • 我無法創建通用的 SELECT count(*) FROM table 查詢,因為我有太多特定的選擇語句.
                  • 我可以運行 preg_replace 來刪除 SELECT 和 FROM 之間的所有內容,然后用 COUNT(*) 替換并運行第二個查詢但這假設所有查詢都以某種方式設置.
                  • 我可以先fetchAll然后count()結果,但這意味著升級if語句的所有實例.
                    • I can't create generic SELECT count(*) FROM table queries as I have too many specific select statements.
                    • I could run a preg_replace to remove everything between SELECT and FROM and then replace with a COUNT(*) and run a second query but this assumes all queries are setup a certain way.
                    • I could fetchAll first then count() the results but that means upgrading all instances of the if statements.
                    • 那么,如果人們將他們的代碼更新為 PDO,那么什么是最好的替代 *_num_rows 函數的方法.不是解決特定問題的東西,而是替代 *_num_rows 功能的東西.如果這是不可能的,以前是什么讓它成為可能的?

                      So what is the best all around replacement to a *_num_rows function if people are updating their code to PDO. Not something that solves a specific problem, but something that replaces the functionality of *_num_rows. If that's not possible what allowed it to be possible before?

                      推薦答案

                      如果你想計算行數,你可以使用 PDO:

                      If you want to count the rows you can do this with PDO:

                      $sql = 'select * from users';
                      $data = $conn->query($sql);
                      $rows = $data->fetchAll();
                      $num_rows = count($rows);
                      

                      如 SELECT 語句與 PDO 一起使用時,無法直接計算行數.rowcount.php" rel="nofollow noreferrer">文檔.

                      There is no way to directly count rows when using a SELECT statement with PDO as stated in the docs.

                      PDOStatement::rowCount() 返回受相應的最后一個 DELETE、INSERTUPDATE 語句影響的行數PDOStatement 對象.

                      PDOStatement::rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement executed by the corresponding PDOStatement object.

                      僅在絕對需要計數時才進行行計數,否則您可以驗證查詢是否與其他方法一起使用.如果您希望從表中返回數千行,您也不應該使用此方法,而是在查詢中使用 COUNT() 函數來執行計數.

                      Only do a row count if you absolutely need the count, otherwise you can verify that the query worked with other methods. You should also not use this method if you expect to be returning thousands of rows from a table, instead, use the COUNT() function in a query for just performing the count.

                      這篇關于相當于 mysql_num_rows 或 mssql_num_rows 的 PDO的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                2. <small id='cEqL3'></small><noframes id='cEqL3'>

                    <tbody id='cEqL3'></tbody>
                  <tfoot id='cEqL3'></tfoot>
                    <bdo id='cEqL3'></bdo><ul id='cEqL3'></ul>

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

                          • 主站蜘蛛池模板: 国产乱码久久久久久一区二区 | 一区二区三区日韩 | 成人av网页 | 成人性视频免费网站 | 一区免费看 | 日本不卡一区二区三区在线观看 | 亚洲 欧美 精品 | 精品二区视频 | 久久国产亚洲 | 国产99在线 | 欧美 | 成人性视频免费网站 | 精品日韩一区二区 | 日韩精品无码一区二区三区 | 久久久久一区二区三区 | 日韩国产在线 | 一片毛片 | 国产精品av久久久久久久久久 | 日韩精品免费视频 | 黄色大全免费看 | 在线不卡视频 | 男女视频在线观看免费 | 久久精品国产a三级三级三级 | 亚洲在线免费 | 精品国产青草久久久久96 | 欧美一区二区三区在线视频 | 宅男伊人 | 91原创视频在线观看 | 欧美精品在线一区 | 日本不卡免费新一二三区 | 国产一区二区在线免费观看 | 色999视频| h网站在线观看 | 久久99精品国产 | 亚洲日本欧美日韩高观看 | 黄网免费 | 青青草视频网 | 精品伊人| 一区二区高清 | 精品啪啪| 逼逼视频 | 亚洲v日韩v综合v精品v |