pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <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="0i8aamk" 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="aiwqg22" 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="imk22sw" 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>
                            主站蜘蛛池模板: 智能风向风速仪,风速告警仪,数字温湿仪,综合气象仪(气象五要素)-上海风云气象仪器有限公司 | 粉末包装机,拆包机厂家,价格-上海强牛包装机械设备有限公司 | 消泡剂_水处理消泡剂_切削液消泡剂_涂料消泡剂_有机硅消泡剂_广州中万新材料生产厂家 | 长沙发电机-湖南发电机-柴油发电机供应厂家-长沙明邦智能科技 | 有机肥设备生产制造厂家,BB掺混肥搅拌机、复合肥设备生产线,有机肥料全部加工设备多少钱,对辊挤压造粒机,有机肥造粒设备 -- 郑州程翔重工机械有限公司 | 法钢特种钢材(上海)有限公司 - 耐磨钢板、高强度钢板销售加工 阀门智能定位器_电液动执行器_气动执行机构-赫尔法流体技术(北京)有限公司 | 电动卫生级调节阀,电动防爆球阀,电动软密封蝶阀,气动高压球阀,气动对夹蝶阀,气动V型调节球阀-上海川沪阀门有限公司 | 仿真植物|仿真树|仿真花|假树|植物墙 - 广州天昆仿真植物有限公司 | 福州时代广告制作装饰有限公司-福州广告公司广告牌制作,福州展厅文化墙广告设计, | 蓝米云-专注于高性价比香港/美国VPS云服务器及海外公益型免费虚拟主机 | BOE画框屏-触摸一体机-触控查询一体机-触摸屏一体机价格-厂家直销-触发电子 | 电伴热系统施工_仪表电伴热保温箱厂家_沃安电伴热管缆工业技术(济南)有限公司 | 蓄电池在线监测系统|SF6在线监控泄露报警系统-武汉中电通电力设备有限公司 | 山东螺杆空压机,烟台空压机,烟台开山空压机-烟台开山机电设备有限公司 | 福州时代广告制作装饰有限公司-福州广告公司广告牌制作,福州展厅文化墙广告设计, | 柔性输送线|柔性链板|齿形链-上海赫勒输送设备有限公司首页[输送机] | 帽子厂家_帽子工厂_帽子定做_义乌帽厂_帽厂_制帽厂 | 品牌设计_VI设计_电影海报设计_包装设计_LOGO设计-Bacross新越品牌顾问 | 雾度仪_雾度计_透光率雾度仪价格-三恩时(3nh)光电雾度仪厂家 | 便携式XPDM露点仪-在线式防爆露点仪-增强型烟气分析仪-约克仪器 冰雕-冰雪世界-大型冰雕展制作公司-赛北冰雕官网 | BESWICK球阀,BESWICK接头,BURKERT膜片阀,美国SEL继电器-东莞市广联自动化科技有限公司 | 螺杆式冷水机-低温冷水机厂家-冷冻机-风冷式-水冷式冷水机-上海祝松机械有限公司 | 精密模具制造,注塑加工,吹塑和吹瓶加工,EPS泡沫包装生产 - 济南兴田塑胶有限公司 | 山楂片_雪花_迷你山楂片_山楂条饼厂家-青州市丰源食品厂 | 钢结构-钢结构厂房-钢结构工程[江苏海逵钢构厂] | 联系我们老街华纳娱乐公司官网19989979996(客服) | 作文导航网_作文之家_满分作文_优秀作文_作文大全_作文素材_最新作文分享发布平台 | 长沙印刷厂-包装印刷-画册印刷厂家-湖南省日大彩色印务有限公司 青州搬家公司电话_青州搬家公司哪家好「鸿喜」青州搬家 | 国际线缆连接网 - 连接器_线缆线束加工行业门户网站 | 课件导航网_ppt课件_课件模板_课件下载_最新课件资源分享发布平台 | 恒温油槽-恒温水槽-低温恒温槽厂家-宁波科麦仪器有限公司 | 利浦顿蒸汽发生器厂家-电蒸汽发生器/燃气蒸汽发生器_湖北利浦顿热能科技有限公司官网 | 常州律师事务所_常州律所_常州律师-江苏乐天律师事务所 | 培训中心-海南香蕉蛋糕加盟店技术翰香原中心官网总部 | 识禅_对禅的了解,从这里开始| 重庆波纹管|重庆钢带管|重庆塑钢管|重庆联进管道有限公司 | 鼓风干燥箱_真空烘箱_高温干燥箱_恒温培养箱-上海笃特科学仪器 | 插针变压器-家用电器变压器-工业空调变压器-CD型电抗器-余姚市中驰电器有限公司 | 消防设施操作员考试报名时间,报名入口,报考条件 | 旋振筛_不锈钢旋振筛_气旋筛_旋振筛厂家—新乡市大汉振动机械有限公司 | 冷凝锅炉_燃气锅炉_工业燃气锅炉改造厂家-北京科诺锅炉 |