I've had situations where database connections appeared to persist following php execution. So, now, my __destructor function explicitly contains a $cxn->close(). It hurts nothing, and helps avoid memory leaks.
mysqli::close
mysqli_close
(PHP 5)
mysqli::close -- mysqli_close — 事前にオープンしているデータベース接続を閉じる
説明
オブジェクト指向型(メソッド):
bool mysqli::close
( void
)
手続き型:
既に開いているデータベース接続を閉じます。
返り値
成功した場合に TRUE を、失敗した場合に FALSE を返します。
例
mysqli_connect() を参照ください。
参考
- mysqli_connect() - 新規に MySQL サーバへの接続をオープンする
- mysqli_init() - MySQLi を初期化し、mysqli_real_connect() で使用するリソースを返す
- mysqli_real_connect() - mysql サーバとの接続をオープンする
mysqli::close
php at dafydd dot com
07-Nov-2008 09:03
07-Nov-2008 09:03
win at alinto dot com
21-May-2008 09:52
21-May-2008 09:52
There's nothing here about connexions automatically claused at the end of a script. About that, a little note from devzone.zend.com :
"Open connections (and similar resources) are automatically destroyed at the end of script execution. However, you should still close or free all connections, result sets and statement handles as soon as they are no longer required. This will help return resources to PHP and MySQL faster."
