Results 1 to 2 of 2

Thread: Difference between mysql_pconnect() and mysql_connect()

  1. #1
    Join Date
    Jul 2012
    Thanked 3 Times in 3 Posts

    Default Difference between mysql_pconnect() and mysql_connect()

    Why it is impossible to to use mysql_pconnect() instead of mysql_connect() to get the maximum result of caching,
    mysql_pconnect() Establishes a persistent connection to a MySQL server. then why mostly prefer mysql_connect() ?
    You will know the truth, and the truth will set you free (John 8:32)(The truth is about the only begotten son of GOD.....When you feel you are alone for facing your problems, God will never leave you by your own You are important for God

  2. #2
    Join Date
    Apr 2008
    Thanked 516 Times in 502 Posts
    Blog Entries


    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.
    Quote Originally Posted by (official PHP website)
    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.

Similar Threads

  1. Difference between PPC and CPC
    By ashleygreen in forum General Paid Work Requests
    Replies: 1
    Last Post: 08-29-2013, 03:14 PM
  2. What's the difference between <td> and <th> tag?
    By heavensgate15 in forum HTML
    Replies: 7
    Last Post: 06-28-2009, 02:10 PM
  3. Difference between GIF and SWF
    By Bornfree in forum Flash
    Replies: 8
    Last Post: 10-20-2007, 02:59 PM
  4. Replies: 4
    Last Post: 09-28-2007, 09:50 PM
  5. difference gif - jpg
    By chechu in forum Graphics
    Replies: 7
    Last Post: 11-17-2006, 03:39 PM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts