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

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

  • <tfoot id='Hj69F'></tfoot>
    1. <legend id='Hj69F'><style id='Hj69F'><dir id='Hj69F'><q id='Hj69F'></q></dir></style></legend>

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

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

        使用 PHP PDO 準備好的語句和 MySQL 選擇字段為空的

        Selecting rows where a field is null using PHP PDO prepared statements and MySQL(使用 PHP PDO 準備好的語句和 MySQL 選擇字段為空的行)

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

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

                  本文介紹了使用 PHP PDO 準備好的語句和 MySQL 選擇字段為空的行的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我一直在將應用程序轉換為使用 PDO 準備好的語句而不是 mysqli,但我遇到了一個奇怪的問題.我在數據庫中有一些記錄,預計字段將為空.不是 'null'(字符串)或 ''(空字符串),而是 NULL.我動態地構建我的查詢,所以過去當我在一個對象中遇到一個空變量時,我會像這樣構建查詢:

                  I've been converting an app to use PDO prepared statements rather than mysqli and I'm running into a strange problem. I have some records in the database where it's expected that a field will be null. Not 'null' (string), or '' (empty string), but NULL. I build my queries dynamically, so in the past when I came across a null variable in an object, I'd build the query like this:

                  WHERE fieldName is null;
                  

                  當字段為空時會得到預期的結果.

                  And would get the expected results when the field was null.

                  現在使用 PDO,我的查詢不會返回任何結果,也不會出現任何錯誤.它只是沒有返回我期望的記錄.當我回顯構建的查詢并直接在 MySQL 中運行它們時,我得到了預期的結果,但在應用程序中沒有返回任何結果.

                  Now with PDO, my queries aren't returning any results and I'm not getting any errors. It just simply isn't returning the records I would expect. When I echo the built queries and run them directly in MySQL I get the expected results, but within the application there are no results returned.

                  我嘗試過的一些事情包括構建如下所示的查詢:

                  Some of the things I've tried include building queries that look like this:

                  WHERE fieldName is null;
                  

                  WHERE fieldName <=> null;
                  

                  我也試過標準的準備語句:

                  I have also tried the standard prepared statement of:

                  WHERE fieldName = :fieldName
                  

                  然后綁定這些類型的語句:

                  and then binding with these kinds of statements:

                  $stmt->bindParam(":$field", $value);
                  $stmt->bindParam(":$field", $value, PDO::PARAM_NULL);
                  $stmt->bindParam(":$field", null, PDO::PARAM_NULL);
                  $stmt->bindValue(":$field", null, PDO::PARAM_NULL);
                  $stmt->bindValue(":$field", null, PDO::PARAM_INT);
                  

                  對此的任何幫助將不勝感激.我的 PHP 版本是 5.3.10,MySQL 是 5.5.22.作為一個附帶問題,我仍然不清楚 bindParam 和 bindValue 之間的區別,所以如果在你的答案中包含它是有意義的,我真的很感激你對這個主題的一些澄清......

                  Any help with this would be greatly appreciated. My PHP version is 5.3.10 and MySQL is 5.5.22. As a side question, I still am not clear on the difference between bindParam and bindValue, so if it makes sense to include in your answer I would really appreciate some clarification on the subject...

                  推薦答案

                  既然已經寫了這個問題,mysql 引入了一個 spaceship operator 允許我們使用常規查詢來匹配空值

                  Since this question has been written, mysql introduced a spaceship operator that allows us to use a regular query to match a null value

                  WHERE fieldName <=> :fieldName;
                  

                  將匹配 null 或任何非空值.

                  will match both a null or any not null value.

                  所以只需立即編寫您的查詢并照常執行

                  So just write your query right away and execute it as usual

                  $stmt = $db->prepare('SELECT field FROM table WHERE fieldName <=> :fieldName;');
                  $stmt->execute(['fieldName' => null]);
                  $result = $stmt->fetchAll(); // whatever fetch method is suitable
                  

                  對于動態構建的查詢,一切都是一樣的.

                  And with dynamically built queries it's all the same.

                  這篇關于使用 PHP PDO 準備好的語句和 MySQL 選擇字段為空的行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

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

                            <tbody id='xzfIl'></tbody>
                          <legend id='xzfIl'><style id='xzfIl'><dir id='xzfIl'><q id='xzfIl'></q></dir></style></legend>

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

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

                          • <i id='xzfIl'><tr id='xzfIl'><dt id='xzfIl'><q id='xzfIl'><span id='xzfIl'><b id='xzfIl'><form id='xzfIl'><ins id='xzfIl'></ins><ul id='xzfIl'></ul><sub id='xzfIl'></sub></form><legend id='xzfIl'></legend><bdo id='xzfIl'><pre id='xzfIl'><center id='xzfIl'></center></pre></bdo></b><th id='xzfIl'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xzfIl'><tfoot id='xzfIl'></tfoot><dl id='xzfIl'><fieldset id='xzfIl'></fieldset></dl></div>
                            <tfoot id='xzfIl'></tfoot>
                            主站蜘蛛池模板: 97超碰站| 国产999在线观看 | 午夜99 | 国产精品久久久 | 成人av一区二区亚洲精 | 午夜资源 | 99re视频在线免费观看 | 国产精品视频中文字幕 | 久久精品91久久久久久再现 | 亚洲三级视频 | 一区二区精品 | 久久亚洲一区二区三区四区 | www.毛片| 国产精品高潮呻吟久久 | av手机在线 | 色一级| 不卡视频在线 | 欧美日韩成人影院 | 免费观看黄a一级视频 | 中文久久 | 九色在线观看 | 欧美视频三区 | 精品国产乱码久久久久久久久 | 中文字幕久久精品 | 国产精品mv在线观看 | 国产精品欧美一区二区三区不卡 | 久久国产亚洲 | 成人片在线看 | 亚洲精品视频久久 | 91国自产| 成人免费一区二区 | 国产免费av在线 | 国产一区91精品张津瑜 | 国产不卡一区 | 在线资源视频 | 日韩欧美第一页 | 亚洲国产精品一区二区三区 | 久久久黑人 | 精品成人免费一区二区在线播放 | 99热都是精品 | 亚洲精选久久 |