本文介紹了為什么構建 PDO 連接很慢?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我在我的 PHP 應用程序中使用 PDO.它連接到同一服務器上的 MySQL 服務器:
I'm using PDO in my PHP application. It connects to a MySQL server on the same server:
$db = new PDO(mysql:host=localhost;dbname=test, $username, $password);
我創建了兩個具有相同輸出的頁面(只是一些純 html 中的虛擬數據),其中一個包含創建 PDO 的調用.如果我打開不使用連接的頁面,響應速度會快 0.5 到 1 秒.
I created two pages with the same output (just some dummy data in plain html) one of which contains the call to create PDO. If I open the page that uses no connection the response is between 0.5 and 1 second quicker.
推薦答案
我一直在做一些谷歌搜索,并且在閱讀了這個線程,我把localhost
改成了127.0.0.1
.這解決了問題....
I've been doing some googling, and after reading this thread, I changed localhost
to 127.0.0.1
. That solves the problem....
這篇關于為什么構建 PDO 連接很慢?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!