日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

php mysql 持久连接_PHP MySQL连接持久性

發(fā)布時(shí)間:2025/3/15 数据库 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php mysql 持久连接_PHP MySQL连接持久性 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

從我閱讀文檔和評論,我看到:

mysql_pconnect上的文檔(不建議使用的方法)

Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use ( mysql_close() will not close links established by mysql_pconnect()).

并對該頁面發(fā)表評論

Persistent connections work well for CGI PHP managed by fastCGI, contrary to the suggestion above that they only work for the module version. That’s because fastCGI keeps PHP processes running between requests. Persistent connections in this mode are easily made immune to connection limits too, because you can set PHP_FCGI_CHILDREN << mysql’s max_connections <<< Apache’s MaxClients. This also saves resources.

關(guān)于mysqli_connect的文檔(新方法)

Prepending host by p: opens a persistent connection. mysqli_change_user() is automatically called on connections opened from the connection pool.

mysqli_change_user的文檔:

Changes the user of the specified database connection and sets the current database.

所以我的理解如下:pconnect在腳本結(jié)束后保持連接打開但是進(jìn)程(或者可能是進(jìn)程組)仍處于活動狀態(tài)(例如在設(shè)置了FCGI的服務(wù)器中).一次只有一個(gè)腳本使用連接,當(dāng)新腳本獲取該連接時(shí),將更新用戶和數(shù)據(jù)庫.

因此,如果使用FCGI和持久連接,則可以減少打開的數(shù)據(jù)庫連接數(shù),但同時(shí)運(yùn)行的腳本將不會共享同一連接.關(guān)于選擇哪個(gè)數(shù)據(jù)庫,連接沒有問題.

總結(jié)

以上是生活随笔為你收集整理的php mysql 持久连接_PHP MySQL连接持久性的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。