php mysqli::close()

來源:互聯網
上載者:User
Anonymous (24-Apr-2010 05:43)

The mysqli_close() function and object method only remove the ability to use the mysql object again in the script, essentially on the surface only nulling out all object parameters.
過程化的mysqli_close()函數和物件導向的方法調用只是不讓使用者在此後的指令碼中再使用mysql對象,基本上只在表面上歸零所有對象參數

At least with PHP5.3.2 and Windows connecting by tcp, this differs by the old mysql_close() function in that it does not actually close out the tcp socket being used. You should always use mysqli_kill() function before mysqli_close() to actually close and free up the tcp socket being used by PHP. Garbage collection after script execution nor mysqli_close() do not kill the tcp socket on their own. The socket would otherwise remain in 'wait' state for approximately 30 seconds, and any additional page loads/connection attempts would only add to the total number of open tcp connections. This wait time does not appear to be configurable via PHP settings.

至少在利用windows的tcp串連的這個版本的php中,舊的函數並沒有真正的關閉正在被使用的tcp串連,你應該總是在調用mysqli_close()前使用mysqli_kill()函數,確保釋放php正在使用的tcp通訊端串連。指令碼結束後執行gc要麼mysqli_close()是不會自己殺掉這個tcp串連的。這個tcp串連會保持大約30秒的等待狀態,期間任何頁面的載入或串連的嘗試都會增加串連的總數,而這個等待時間似乎在php的設定檔中是不能設定的


Also as of this version, mysqli created links cannot be "deactivated", and will continue to accumulate in process memory until the PHP server or process is restarted, essentially making mysqli.max_links = -1 required.

另外在這個版本中,mysqli建立的串連是不能被設定為無效的,而且串連會在這個進程中積累,知道php伺服器或者進程重啟,所以可以設定mysqli.max_links = -1

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.