First and foremost,
# If at all possible, you should avoid using the mysql_* functions. #
Existing code should be updated to avoid performance and security problems.
ext/mysql is outdated and has not been a recommended "best practice" since
2004.

Originally Posted by
php.net (official PHP website)
Warning
This extension is
deprecated as of PHP 5.5.0, and
is not recommended for writing new code as it will be removed in the future.
Instead, either the
mysqli or
PDO_MySQL extension should be used.
See also the
MySQL API Overview for further help while choosing a MySQL API.
As for persistent connections,
They are still available, of course, when you use MySQLi or PDO, and you can use them if you want to. However, persistent connections don't always carry the benefits you expect them to. To start with, under Apache, a new process is usually spawned per request anyway, so there is no opportunity to re-use the connection. It will simply sit, idle, in its original process until Apache decides to kill it. In the meantime, MySQL is still devoting resources to it, and it's still in the connection pool so it still counts towards your maximum number of connections. If you have a moderately busy site (or a sudden spike in activity; maybe a hundred or so visitors at once), you can easily lock out your DB server.
Also, to clarify, persistent connections have nothing to do with "caching." They operate directly on the DB, like any other connection.
Read more.
Bookmarks