SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How to know number of connection open for mysql using php

    Hi i want to know how many connection is opened in php ,which one is best to mysql_connect and mysql_pconnect ?

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    pconnect will open a persistent connection. If one is already open using the same user/pass identifier, it will use that one, and thus you would (should) only have 1 connection open at a time.
    connect will open a connection for the length of execution of the script (or until mysql_close() is called).

    Note: Use of the MySQL library is now considered discouraged. Consider using the mysqli or PDO libraries.

    The number of opened connections to a mysql server can be found by issuing a query for SHOW STATUS; this will, among other things, return a field for Threads_connected
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you have to run the query to get the number of connections as said.

  4. #4
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    should i use mysql_close() after every connection open ,else it will automatically close


Bookmarks

Posting Permissions

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