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

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

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

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

    1. <tfoot id='dvX23'></tfoot>

      1. <legend id='dvX23'><style id='dvX23'><dir id='dvX23'><q id='dvX23'></q></dir></style></legend>

        Php PDO rowCount() 返回錯誤結果

        Php PDO rowCount() return wrong result(Php PDO rowCount() 返回錯誤結果)
      2. <tfoot id='4eZUh'></tfoot>

        <small id='4eZUh'></small><noframes id='4eZUh'>

          <bdo id='4eZUh'></bdo><ul id='4eZUh'></ul>

              <tbody id='4eZUh'></tbody>

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

                  本文介紹了Php PDO rowCount() 返回錯誤結果的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個在樹結構數據中獲取路徑的函數.

                  I have a function for getting path in a tree structure data.

                  根據我在數據庫中的表,當我查詢 sub_id='root_id'

                  According to my table in DB, root should get no result when I query sub_id='root_id'

                  當我剛剛通過根時,rowCount 返回正確的結果,即 0.但是,當我從較低等級(第 3 位)傳遞一個節點時,在遞歸的末尾,即根,rowCount 返回 1?

                  When I just pass the root the rowCount return correct result which is 0. However when I pass a node from lower rank(3rd), in the end of the recursive which is root, rowCount return 1?

                  附注

                  我使用 Mysql 作為數據庫

                  I use Mysql as DB

                  這是我的桌子

                  main_id | sub_id
                  ----------------    
                      1   |    2    
                      1   |    3    
                      2   |    4    
                      3   |    5
                  

                  代碼:

                  $stmt = $conn->prepare("Select * from table where sub_id= ? ");  
                  
                  function get_path($stmt,$node,&$map){
                  
                      $res=$stmt->execute(array($node));
                  
                      if(!$res){ throw new Exception( implode(' ',$stmt->errorInfo()),1); }
                  
                          echo $node.' found '.$stmt->rowCount().'<br>';
                  
                          if($stmt->rowCount()==0){ //root
                              $map[]=$node;
                          }else{
                  
                              foreach($stmt->fetchAll(PDO::FETCH_ASSOC) AS $row){
                                  $map[]=$node;
                                  $upper_node=$row['main_id'];
                                  get_path($stmt,$upper_node,$map);
                          }
                      }
                  
                  }
                  

                  如果我只是通過 get_path($stmt,1,$map);(根)

                  If I just pass get_path($stmt,1,$map); (the root)

                  輸出:

                  1 found 0
                  

                  但是當我例如將 4 傳遞給它時輸出變成:

                  but when I for example pass 4 into it the output become:

                  4 found 1
                  2 found 1
                  1 found 1 <= it should found 0
                  

                  為什么?

                  推薦答案

                  你不應該依賴 PDOStatement::rowCount() 來獲取受 SELECT 語句影響的行數,參見 PHP 手冊,PDOStatement::rowCount:

                  You shouldn't rely on PDOStatement::rowCount() to get the number of rows affected by a SELECT statement, see PHP manual, PDOStatement::rowCount:

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

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

                  如果關聯的 PDOStatement 執行的最后一條 SQL 語句是一條 SELECT 語句,某些數據庫可能會返回行數該語句返回.但是,不能保證此行為適用于所有數據庫,不應依賴于可移植應用程序.

                  If the last SQL statement executed by the associated PDOStatement was a SELECT statement, some databases may return the number of rows returned by that statement. However, this behaviour is not guaranteed for all databases and should not be relied on for portable applications.

                  [...]

                  示例 #2 對 SELECT 語句返回的行進行計數

                  Example #2 Counting rows returned by a SELECT statement

                  對于大多數數據庫,PDOStatement::rowCount() 不返回受 SELECT 語句影響的行數.相反,使用PDO::query() 發出一個 SELECT COUNT(*) 語句謂詞作為您想要的 SELECT 語句,然后使用PDOStatement::fetchColumn() 來檢索將要執行的行數被退回.然后,您的應用程序可以執行正確的操作.

                  For most databases, PDOStatement::rowCount() does not return the number of rows affected by a SELECT statement. Instead, use PDO::query() to issue a SELECT COUNT(*) statement with the same predicates as your intended SELECT statement, then use PDOStatement::fetchColumn() to retrieve the number of rows that will be returned. Your application can then perform the correct action.

                  這篇關于Php PDO rowCount() 返回錯誤結果的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 找不到驅動程序)
                  <tfoot id='2yhiP'></tfoot>
                      <tbody id='2yhiP'></tbody>
                      • <bdo id='2yhiP'></bdo><ul id='2yhiP'></ul>

                        1. <i id='2yhiP'><tr id='2yhiP'><dt id='2yhiP'><q id='2yhiP'><span id='2yhiP'><b id='2yhiP'><form id='2yhiP'><ins id='2yhiP'></ins><ul id='2yhiP'></ul><sub id='2yhiP'></sub></form><legend id='2yhiP'></legend><bdo id='2yhiP'><pre id='2yhiP'><center id='2yhiP'></center></pre></bdo></b><th id='2yhiP'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='2yhiP'><tfoot id='2yhiP'></tfoot><dl id='2yhiP'><fieldset id='2yhiP'></fieldset></dl></div>
                          1. <small id='2yhiP'></small><noframes id='2yhiP'>

                          2. <legend id='2yhiP'><style id='2yhiP'><dir id='2yhiP'><q id='2yhiP'></q></dir></style></legend>
                            主站蜘蛛池模板: 剑来高清在线观看 | 中文日韩在线 | 亚洲免费高清 | 亚洲高清成人在线 | 视频一区二区三区中文字幕 | 国产精品高潮呻吟久久 | 国产精品一区二区在线播放 | 亚洲精品免费观看 | 久久噜噜噜精品国产亚洲综合 | 一区免费 | 久久国产精品一区二区三区 | 久久久久国产一级毛片高清网站 | 一区二区三区四区不卡视频 | 中文一区二区 | 天天操夜夜看 | 色小姐综合网 | 国产一区www | 欧美在线一区二区三区 | 成人免费一区二区三区牛牛 | 激情久久久久 | 久久精品一区 | 久久69精品久久久久久久电影好 | 日韩精品一区二区三区在线播放 | 国产精品自拍视频网站 | 精品国产乱码久久久久久中文 | 91在线免费视频 | 亚洲午夜视频 | 97影院2| 东方伊人免费在线观看 | 黄网免费看 | 男人天堂免费在线 | 羞羞色视频 | 毛片免费在线观看 | 91在线观看免费视频 | 网站一区二区三区 | 成人欧美一区二区三区视频xxx | 亚洲视频在线观看 | 羞羞的视频免费在线观看 | 日本a∨视频 | 久久免费资源 | 国产成人在线视频免费观看 |