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

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

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

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

      檢查空結(jié)果(PHP、PDO 和 MySQL)

      Checking for an empty result (PHP, PDO, and MySQL)(檢查空結(jié)果(PHP、PDO 和 MySQL))

        <tbody id='swIyu'></tbody>

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

          • <bdo id='swIyu'></bdo><ul id='swIyu'></ul>
              <i id='swIyu'><tr id='swIyu'><dt id='swIyu'><q id='swIyu'><span id='swIyu'><b id='swIyu'><form id='swIyu'><ins id='swIyu'></ins><ul id='swIyu'></ul><sub id='swIyu'></sub></form><legend id='swIyu'></legend><bdo id='swIyu'><pre id='swIyu'><center id='swIyu'></center></pre></bdo></b><th id='swIyu'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='swIyu'><tfoot id='swIyu'></tfoot><dl id='swIyu'><fieldset id='swIyu'></fieldset></dl></div>
                <legend id='swIyu'><style id='swIyu'><dir id='swIyu'><q id='swIyu'></q></dir></style></legend>
                <tfoot id='swIyu'></tfoot>
                本文介紹了檢查空結(jié)果(PHP、PDO 和 MySQL)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我在這里做錯了什么?我只是從表中檢索結(jié)果,然后將它們添加到數(shù)組中.一切都按預(yù)期工作,直到我檢查結(jié)果為空...

                What am I doing wrong here? I'm simply retrieving results from a table and then adding them to an array. Everything works as expected until I check for an empty result...

                這會得到匹配項,將其添加到我的數(shù)組中并按預(yù)期回顯結(jié)果:

                This gets the match, adds it to my array and echoes the result as expected:

                $today = date('Y-m-d', strtotime('now'));
                
                $sth = $db->prepare("SELECT id_email FROM db WHERE hardcopy = '1' AND hardcopy_date <= :today AND hardcopy_sent = '0' ORDER BY id_email ASC");
                
                $sth->bindParam(':today', $today, PDO::PARAM_STR);
                
                if(!$sth->execute()) {
                    $db = null;
                    exit();
                }
                
                while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
                    $this->id_email[] = $row['id_email'];
                    echo $row['id_email'];
                }
                
                $db = null;
                return true;
                

                當(dāng)我嘗試檢查空結(jié)果時,我的代碼返回空",但不再產(chǎn)生匹配的結(jié)果:

                When I try to check for an empty result, my code returns 'empty', but no longer yields the matching result:

                $today = date('Y-m-d', strtotime('now'));
                
                $sth = $db->prepare("SELECT id_email FROM db WHERE hardcopy = '1' AND hardcopy_date <= :today AND hardcopy_sent = '0' ORDER BY id_email ASC");
                
                $sth->bindParam(':today',$today, PDO::PARAM_STR);
                
                if(!$sth->execute()) {
                    $db = null;
                    exit();
                }
                
                if ($sth->fetchColumn()) {
                    echo 'not empty';
                    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
                        $this->id_email[] = $row['id_email'];
                        echo $row['id_email'];
                    }
                    $db = null;
                    return true;
                }
                echo 'empty';
                $db = null;
                return false;
                

                推薦答案

                當(dāng)您執(zhí)行 $sth->fetchColumn() 時,您將丟棄結(jié)果行.這不是您檢查是否有任何結(jié)果的方式.你做

                You're throwing away a result row when you do $sth->fetchColumn(). That's not how you check if there are any results. You do

                if ($sth->rowCount() > 0) {
                  ... got results ...
                } else {
                   echo 'nothing';
                }
                

                相關(guān)文檔在這里:PDOStatement::rowCount

                Relevant documentation is here: PDOStatement::rowCount

                這篇關(guān)于檢查空結(jié)果(PHP、PDO 和 MySQL)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                MySQLi prepared statement amp; foreach loop(MySQLi準(zhǔn)備好的語句amp;foreach 循環(huán))
                Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務(wù)器還是從同一用戶獲取記錄?)
                PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數(shù))
                Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結(jié)果填充變量)
                MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“l(fā)ocalhost的訪問被拒絕)

                  <tbody id='IppbS'></tbody>

                  <bdo id='IppbS'></bdo><ul id='IppbS'></ul>
                • <legend id='IppbS'><style id='IppbS'><dir id='IppbS'><q id='IppbS'></q></dir></style></legend>

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

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

                        • <tfoot id='IppbS'></tfoot>

                        • 主站蜘蛛池模板: 午夜精品一区二区三区在线观看 | 日韩中文字幕一区 | japan25hdxxxx日本 做a的各种视频 | 一区二区三区免费看 | 国产成人免费视频 | 视频一区在线观看 | 国产中文一区二区三区 | caoporn国产精品免费公开 | 狠狠综合久久av一区二区小说 | 久久免费视频1 | 国产乱码精品1区2区3区 | 久久性av | 午夜影院黄 | 日屁网站 | 91精品国产777在线观看 | 美女131mm久久爽爽免费 | 亚洲一区二区三区在线视频 | 久久精品欧美一区二区三区麻豆 | 国产一区二区三区精品久久久 | 亚洲精品成人网 | 成人自拍av | 人人爽人人爽人人片av | 超碰精品在线 | 精品无码久久久久国产 | 国产精品a免费一区久久电影 | 毛色毛片免费看 | 国产欧美精品一区二区色综合朱莉 | 久久丁香 | 七七婷婷婷婷精品国产 | 天天噜天天干 | 久久久九九九九 | 国产免费xxx| 久久久久高清 | 久热久热| 中文字幕av一区二区三区 | 日韩伦理一区二区 | 国产精品久久久久久久久久久久久久 | 久久久噜噜噜www成人网 | www.色午夜.com | 欧美一区二区三区在线 | 日韩一区二区三区在线视频 |