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

  1. <small id='Ml1pf'></small><noframes id='Ml1pf'>

    <tfoot id='Ml1pf'></tfoot>

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

      如何使用 PHP 的 PDO 檢查數(shù)據(jù)庫查詢返回的結(jié)果

      How do I check db query returned results using PHP#39;s PDO(如何使用 PHP 的 PDO 檢查數(shù)據(jù)庫查詢返回的結(jié)果)
      <tfoot id='UseeV'></tfoot>
        <tbody id='UseeV'></tbody>

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

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

          <legend id='UseeV'><style id='UseeV'><dir id='UseeV'><q id='UseeV'></q></dir></style></legend>

              • <bdo id='UseeV'></bdo><ul id='UseeV'></ul>
                本文介紹了如何使用 PHP 的 PDO 檢查數(shù)據(jù)庫查詢返回的結(jié)果的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                如何在 PHP 中使用 PDO 檢查我的結(jié)果集是否為空?

                How do I check if my result set is empty using PDO in PHP?

                $SQL = "SELECT ......... ORDER BY lightboxName ASC;";
                $STH = $DBH->prepare($SQL);
                $STH->bindParam(':member_id', $member_id);
                $STH->execute();
                $STH->setFetchMode(PDO::FETCH_ASSOC);
                
                while($row = $STH->fetch()) {
                    $lightbox_name = $row['lightboxName'];
                    $lightbox_id = $row['lightboxID'];
                    echo '<option value="'.$lightbox_id.'">'.$lightbox_name.'</option>';
                }
                

                我以前是這樣做的:

                $result = mysql_query("SELECT ...... ORDER BY lightboxName ASC;");
                if(!$result) { echo 'No results found!'; }
                

                但是剛剛開始使用 PDO 和準備好的語句并且檢查 $STH 似乎沒有按預期工作 - 它總是有價值的!

                But have just started using PDO and prepared statements and checking against $STH does not seem to work as expected — it always has value!

                推薦答案

                我會嘗試使用 rowCount():

                I would try to use rowCount():

                $rows_found = $STH->rowCount();
                

                但是,根據(jù)手冊:

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

                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.

                如果它不適合您,您可以使用手冊中提到的其他方法.

                If it does not work for you, you can use the other method mentioned in the manual.

                您當然也可以在 while 循環(huán)之前設置一個變量,在循環(huán)中更改它并檢查循環(huán)后的值...

                You can of course also set a variable before your while loop, change it in your loop and check the value after the loop...

                這篇關于如何使用 PHP 的 PDO 檢查數(shù)據(jù)庫查詢返回的結(jié)果的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關文檔推薦

                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 找不到驅(qū)動程序)
                1. <legend id='6uick'><style id='6uick'><dir id='6uick'><q id='6uick'></q></dir></style></legend>

                  <small id='6uick'></small><noframes id='6uick'>

                  • <bdo id='6uick'></bdo><ul id='6uick'></ul>
                        <tbody id='6uick'></tbody>
                      <tfoot id='6uick'></tfoot>

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

                        1. 主站蜘蛛池模板: 久久精品国产亚洲一区二区 | 国产精品久久久久久久久久 | 成人精品视频在线观看 | 午夜视频网站 | 成人久久18免费网站图片 | 一级免费毛片 | 久久香蕉网| 国产a区| 在线成人 | 国产精品日日摸夜夜添夜夜av | 久久久久久久久久久福利观看 | 一级片免费视频 | 欧美性区| 少妇午夜一级艳片欧美精品 | 亚洲精品乱码久久久久久按摩观 | 国产精品久久久久久福利一牛影视 | 欧美一级二级在线观看 | 懂色av蜜桃av | 成人在线精品视频 | 国产精品欧美一区二区 | 成人特级毛片 | 欧美午夜精品 | 欧美一级在线观看 | 天天看天天操 | 日本午夜免费福利视频 | 国产日韩欧美激情 | 午夜视频免费在线观看 | 亚洲一区 中文字幕 | 在线播放日韩 | 一级在线毛片 | 正在播放一区二区 | 国产成人综合在线 | 欧美日韩在线免费 | 精品九九在线 | 国产精品久久二区 | 欧美视频一区二区三区 | 在线免费观看欧美 | 久久com| 美女黄视频网站 | 在线免费观看亚洲 | 在线看91 |