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

<legend id='RNzDV'><style id='RNzDV'><dir id='RNzDV'><q id='RNzDV'></q></dir></style></legend><tfoot id='RNzDV'></tfoot>

      <bdo id='RNzDV'></bdo><ul id='RNzDV'></ul>
  1. <small id='RNzDV'></small><noframes id='RNzDV'>

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

    2. PHP:使用 PDO 從 MySQL 檢索圖像

      PHP: Retrieve image from MySQL using PDO(PHP:使用 PDO 從 MySQL 檢索圖像)

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

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

          <tfoot id='s6BY7'></tfoot>

        1. <legend id='s6BY7'><style id='s6BY7'><dir id='s6BY7'><q id='s6BY7'></q></dir></style></legend>

              <bdo id='s6BY7'></bdo><ul id='s6BY7'></ul>
              • 本文介紹了PHP:使用 PDO 從 MySQL 檢索圖像的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                我正在重構(gòu)一些舊代碼,包括重寫基本的 mysql 查詢以使用 PDO.

                I am refactoring some old code, including rewriting basic mysql queries to use PDO.

                以下適用于所有瀏覽器和所有圖像類型:

                The following works brilliantly in all browsers and for all image types:

                $query = 'SELECT image FROM image WHERE imageid=' . $image_id;
                $result = mysql_query($query, $db_conn); querycheck($result);
                header("Content-type: image");
                echo mysql_result($result, 0);
                

                不幸的是,盡管我使用 PDO 重寫了它,但它不起作用.我已經(jīng)瀏覽了整個(gè) PDO 文檔和標(biāo)準(zhǔn)的網(wǎng)絡(luò)搜索,但沒(méi)有任何建議/解決方案有效.

                Unfortunately, however I rewrite it using PDO, it doesn't work. I've been through the entire PDO documentation and the standard web search, but none of the advice/solutions work.

                如何使用 PDO 從 MySQL 中輕松獲取圖像并顯示它?

                How can one easily fetch and image from MySQL using PDO and display it?

                編輯 1:

                Matthew Ratzloff 給出了下面應(yīng)該是顯而易見(jiàn)的答案,但它不起作用.這是我使用 PDO 測(cè)試的實(shí)際代碼(我嘗試了許多變體/參數(shù)):

                Matthew Ratzloff gives what should be the obvious answer below, but it does not work. Here is the actual code that I test using PDO (and I have tried many variants/parameters):

                $connectstring_temp = 'mysql:host=' . $A . ';dbname=' .$B;
                $dbh_temp = new PDO($connectstring_temp, $login, $password);
                #$dbh_temp->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                #$dbh_temp->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);
                
                $sql = "SELECT image FROM image WHERE imageid=" . $image_id;
                $query = $dbh_temp->prepare($sql);
                $query->execute();
                
                $query->bindColumn(1, $image, PDO::PARAM_LOB);
                $query->fetch(PDO::FETCH_BOUND);
                header("Content-Type: image");
                echo $image;
                

                我保留了相同的語(yǔ)法,但最終代碼 $image_id 需要作為參數(shù)傳遞.上面的代碼不起作用.PDO 適用于所有類型的所有其他查詢.

                I've kept the same syntax, although for the final code $image_id needs to be passed as a parameter. The code above does NOT work. PDO works fine for all other queries of all types.

                推薦答案

                需要參數(shù)化imageid值并將參數(shù)綁定到PDO::PARAM_LOB:

                You need to paramaterize the imageid value and bind the parameter to PDO::PARAM_LOB:

                $sql = "SELECT image FROM image WHERE imageid=:id";
                $query = $db_conn->prepare($sql);
                $query->execute(array(':id' => $image_id));
                
                $query->bindColumn(1, $image, PDO::PARAM_LOB);
                $query->fetch(PDO::FETCH_BOUND);
                header("Content-Type: image");
                echo $image;
                

                當(dāng)然,您還需要指定完整、正確的內(nèi)容類型(例如,圖像/png).

                Of course, you'll also want to specify the complete, correct content type (e.g., image/png).

                這篇關(guān)于PHP:使用 PDO 從 MySQL 檢索圖像的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                MySQLi prepared statement amp; foreach loop(MySQLi準(zhǔn)備好的語(yǔ)句amp;foreach 循環(huán))
                Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個(gè)服務(wù)器還是從同一用戶獲取記錄?)
                PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無(wú)法識(shí)別登錄信息)
                mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個(gè)參數(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的訪問(wèn)被拒絕)
                • <bdo id='JSkFu'></bdo><ul id='JSkFu'></ul>

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

                    <tfoot id='JSkFu'></tfoot>
                      • <small id='JSkFu'></small><noframes id='JSkFu'>

                          <tbody id='JSkFu'></tbody>
                      • <i id='JSkFu'><tr id='JSkFu'><dt id='JSkFu'><q id='JSkFu'><span id='JSkFu'><b id='JSkFu'><form id='JSkFu'><ins id='JSkFu'></ins><ul id='JSkFu'></ul><sub id='JSkFu'></sub></form><legend id='JSkFu'></legend><bdo id='JSkFu'><pre id='JSkFu'><center id='JSkFu'></center></pre></bdo></b><th id='JSkFu'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='JSkFu'><tfoot id='JSkFu'></tfoot><dl id='JSkFu'><fieldset id='JSkFu'></fieldset></dl></div>
                          主站蜘蛛池模板: 在线日韩视频 | 国产精久久久久久 | 四虎影院在线观看av | 国产精品资源在线 | 国产精品海角社区在线观看 | 国产精品久久久久久久久久久久 | 亚洲一区二区久久 | 亚洲精品视频免费观看 | 国产高清免费视频 | 国产伦精品一区二区三区照片91 | 亚洲欧美综合精品久久成人 | 精品国产乱码久久久久久蜜柚 | 91综合网| 亚洲欧美在线免费观看 | 国产婷婷精品av在线 | 国产不卡在线观看 | 成人一区在线观看 | 在线观看成人 | 午夜久久久久久久久久一区二区 | 久久精品国产精品青草 | 欧洲妇女成人淫片aaa视频 | 视频在线亚洲 | av中文字幕在线播放 | 91久久精品国产91久久 | 一区二区三区视频在线免费观看 | 免费簧片视频 | 高清av一区 | 亚洲一区二区av | 91私密视频| 日韩视频一区二区三区 | 亚洲成人免费av | 国产精品久久av | www.97zyz.com| 国产欧美日韩 | 欧美一级α片 | 国产精品久久久久久久7777 | 亚洲成人国产 | 91在线观看视频 | 久久久久久久久综合 | 99久久精品国产毛片 | 看片国产 |