goldensona — 2012-07-30T05:14:41-04:00 — #1
Hi i want to know how many connection is opened in php ,which one is best to mysql_connect and mysql_pconnect ?
starlion — 2012-07-31T09:07:54-04:00 — #2
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
bplaza — 2012-08-03T15:01:19-04:00 — #3
you have to run the query to get the number of connections as said.
goldensona — 2013-01-28T01:39:39-05:00 — #4
should i use mysql_close() after every connection open ,else it will automatically close