2

PHP doc says "mysql_close() will not close persistent links".

Is it the same with mysqli (mysqli::close()) ?

lacorbeille
  • 325
  • 1
  • 4
  • 8

2 Answers2

2

No. The mysql_close() function closes only non persistent links. You can't close persistent links.

mysql_close() closes the non-persistent connection to the MySQL server that's associated with the specified link identifier. If link_identifier isn't specified, the last opened link is used.

source:php.net

Pethical
  • 1,472
  • 11
  • 18
  • 1
    Just wanted to post the same :) There's no reliable way to close a persistent connection from PHP. A workaround would be to set MySQLs wait_timeout to a low value: [link](http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_wait_timeout) – Jan Petzold Jun 01 '12 at 10:51
  • ok I knew for mysql_close() but wanted to be sure it's the same for msqli::close()... "There's no reliable way to close a persistent connection from PHP" seems like a definitive answer. thank you. – lacorbeille Jun 01 '12 at 12:52
  • 1
    "You can't close persistent links." So, you can not close this links with any of functions, methods, classes, macros, directives in php and all of extensions, modules. If you must close, restart the mysql server process! – Pethical Jun 01 '12 at 12:56
2

Mysqli contains a built in auto cleanup which will close a handler.

You may want to have a read of http://php.net/manual/en/mysqli.persistconns.php

ashryalls
  • 308
  • 2
  • 5