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

      <bdo id='8updR'></bdo><ul id='8updR'></ul>
    <tfoot id='8updR'></tfoot>
  • <small id='8updR'></small><noframes id='8updR'>

  • <legend id='8updR'><style id='8updR'><dir id='8updR'><q id='8updR'></q></dir></style></legend>

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

        使用 PDO 設置連接超時

        Setting a connect timeout with PDO(使用 PDO 設置連接超時)
          <tfoot id='tm5SM'></tfoot>

            <tbody id='tm5SM'></tbody>
          • <small id='tm5SM'></small><noframes id='tm5SM'>

          • <legend id='tm5SM'><style id='tm5SM'><dir id='tm5SM'><q id='tm5SM'></q></dir></style></legend>

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

                1. 本文介紹了使用 PDO 設置連接超時的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在使用 PDO 從 MySQL 服務器獲取數據.我注意到的是:如果 MySQL 服務器不可用,這段代碼需要真的(相對)很長時間才能返回異常:

                  I'm using PDO to get data off a MySQL server. What I noticed is this: if the MySQL server is unavailable, it takes really (relatively) long for this code to return an exception:

                  try {
                    $handle = new PDO($db_type . ':host='.$db_host.';dbname='.$db_name,$db_user,$db_pass);
                    // Tried using PDO::setAttribute and PDO::ATTR_TIMEOUT here
                  } catch(PDOException $e) {
                    echo $e->getMessage;
                  }
                  

                  在 MySQL 的情況下,異常發生只需要 2 分鐘多一點(SQLSTATE[HY000] [2003] Can't connect to MySQL server on...)和 30 秒在 PostgreSQL (SQLSTATE[08006] [7] 超時已過期).

                  In case of MySQL it takes just over 2 minutes for the exception to occur (SQLSTATE[HY000] [2003] Can't connect to MySQL server on...) and 30 seconds on PostgreSQL (SQLSTATE[08006] [7] timeout expired).

                  我嘗試使用 PDO::setAttribute 和 PDO::ATTR_TIMEOUT 但它不起作用.我想這是有道理的,因為問題發生在此語句之前.

                  I tried using PDO::setAttribute and PDO::ATTR_TIMEOUT but it's not working. Which I guess makes sense, since the problem occurs before this statement.

                  有沒有辦法設置連接數據庫的超時時間?2 分鐘/30 秒對我來說似乎很長,讓 PDO 意識到那里什么都沒有.

                  Is there a way to set a timeout for connecting to the DB? 2 minutes/30 seconds seems really long to me for PDO to realize there is nothing there.

                  我想我在某處看到過這種情況,但我一輩子都找不到了.

                  I think I saw this being done somewhere, but can't find it again for the life of me.

                  推薦答案

                  $DBH = new PDO(
                      "mysql:host=$host;dbname=$dbname", 
                      $username, 
                      $password,
                      array(
                          PDO::ATTR_TIMEOUT => 5, // in seconds
                          PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
                      )
                  );
                  

                  這篇關于使用 PDO 設置連接超時的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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的訪問被拒絕)
                  <i id='0lkRa'><tr id='0lkRa'><dt id='0lkRa'><q id='0lkRa'><span id='0lkRa'><b id='0lkRa'><form id='0lkRa'><ins id='0lkRa'></ins><ul id='0lkRa'></ul><sub id='0lkRa'></sub></form><legend id='0lkRa'></legend><bdo id='0lkRa'><pre id='0lkRa'><center id='0lkRa'></center></pre></bdo></b><th id='0lkRa'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='0lkRa'><tfoot id='0lkRa'></tfoot><dl id='0lkRa'><fieldset id='0lkRa'></fieldset></dl></div>

                      <tbody id='0lkRa'></tbody>
                    • <legend id='0lkRa'><style id='0lkRa'><dir id='0lkRa'><q id='0lkRa'></q></dir></style></legend>

                          <bdo id='0lkRa'></bdo><ul id='0lkRa'></ul>

                          <small id='0lkRa'></small><noframes id='0lkRa'>

                            <tfoot id='0lkRa'></tfoot>
                            主站蜘蛛池模板: av男人的天堂av | 亚洲国产精品第一区二区 | 中文字幕 视频一区 | 亚洲精品视频免费观看 | 国产精品不卡 | 久久久精彩视频 | 亚洲大片 | 91精品国产91久久久久久最新 | 99精品九九 | 久草网站 | 日韩电影免费在线观看中文字幕 | 青青操91| 91精品久久久久久久久久入口 | 久久com| 三级黄色片在线播放 | 天天干天天爱天天爽 | 成人在线观看免费 | 日韩高清国产一区在线 | 成人久久视频 | 国产在线a | 欧美日韩电影免费观看 | 颜色网站在线观看 | 日本中文在线 | 日韩和的一区二区 | 国产精品第2页 | 亚洲第一av | 日韩a在线 | 午夜影视网 | 免费在线观看黄网站 | 中文字幕精品一区 | 精品视频在线观看 | 日韩欧美三级 | 日韩精品在线一区 | 国产精品美女久久久久久免费 | 91日日| 国产剧情一区二区三区 | 欧美精品啪啪 | 日韩在线视频免费观看 | 国产91在线观看 | 国产成人久久精品一区二区三区 | 亚洲手机视频在线 |