* Thus wrote anders thoresson ([EMAIL PROTECTED]):
> 
> function db_connect ($user, $pwd, $db, $debug = 0)
> {
>       $link = @mysql_pconnect("localhost", "$user", "$pwd");
>       if($link && mysql_select_db("$db"))
> ... 
>
> I thought that making another or a third call to db_connect would reuse 
> the same connection to the database, since I use mysql_pconnect() to 
> connect. But listing the active processes indicates something else:
> 
> 
> | Id    | User  | Host      | db    | Command | Time | State | Info         
> | 64494 | thore | localhost | thore | Sleep   | 222  |       |              
>    |
> | 64497 | thore | localhost | thore | Sleep   | 218  |       |              
>    |
> ...

This is expected, this is the behavour of mysql. when php requests
a pconnection, mysql will allocate a certain amount of pooled
connections that will be used.

To really test this to see if php is reusing the connection, kill
all processes in mysql. Then (making sure that no other script
somewhere else connects to database) run your script once.  Your
resulting process list will have only one item listed

the second time you request in php you'll have two, and so on.
Until the number of connections in the pool gets filled up will
mysql tell php to use an id that exists.

there is a setting in mysql to change this, but i can't recall off
hand the name of the setting.

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to