久久久久久久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 檢查數據庫查詢返回的結果

      How do I check db query returned results using PHP#39;s PDO(如何使用 PHP 的 PDO 檢查數據庫查詢返回的結果)
      <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 檢查數據庫查詢返回的結果的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

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

                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();
                

                但是,根據手冊:

                如果關聯的 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.

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

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

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

                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 檢查數據庫查詢返回的結果的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 找不到驅動程序)
                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. 主站蜘蛛池模板: 超碰99在线 | 亚洲天堂av在线 | 成年人国产 | 日日夜夜人人 | 日韩久久久久久久 | av影片在线观看 | 国产区免费 | 国产精品va | 久久精品国产一区 | www.国产一区| 不卡av在线播放 | 日本免费中文字幕 | 成人午夜激情 | 日韩手机看片 | 九九精品免费视频 | 黄色国产| 亚洲欧美综合另类 | 久久国产99 | 日本国产欧美 | 亚洲国产精品网站 | 精品视频一区二区 | 亚洲另类视频 | 久久精品福利视频 | 精品一区二区在线视频 | 成人国产在线观看 | 日本精品免费 | 国产精品久久久久久久久久久久午夜片 | 亚洲精品久久久久久久久久久 | 免费福利片 | 免费一区二区 | 国产黄色片视频 | 国产精选av | 亚洲天天看 | 91久久精品日日躁夜夜躁欧美 | 黄色片网站在线观看 | 久久久精品影院 | 黄色一区二区三区 | 成年人免费视频网站 | 九九九视频 | av不卡在线观看 | 国产又粗又大又硬 |