問題描述
剛開始使用mysqli.如果我在小型網站上使用小型數據集(流量方面),我真的需要一直使用這些嗎?
Just started using mysqli. If I'm working with small data sets on small websites (traffic-wise), do I really need to use these all the time?
$result->close();
$mysqli->close();
另外,對于在沒有框架的情況下進行自定義 PHP 和 MySQL 工作的人來說,mysqli 是與 MySQL 交互的一般首選方式嗎?
Also, for someone doing custom PHP and MySQL work without a framework, is mysqli the general preferred way of interacting with MySQL?
推薦答案
PHP 將在腳本結束時關閉所有打開的文件和數據庫連接.完成連接后手動執行此操作是一種很好的做法,但如果不這樣做也無濟于事.如果您有一個將在整個腳本中使用的數據庫連接,您也可以將其保持打開狀態.
PHP will close all open files and DB connections at the end of the script. It's good practice to do it manually when you are done with the connections, but it's no disaster if you don't. If you have a DB connection that will be used throughout the whole script you can as well leave it open.
+1 對 PDO
這篇關于mysqli - 我真的需要做 $result->close();&$mysqli->close();?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!