Re: mysql_pconnect & mysql_connect
| From: | jtjohnston | Date: | Thu, 03 Jan 2002 05:17:27 +0000 |
| Subject: | Re: mysql_pconnect & mysql_connect | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-82866@lists.php.net to get a copy of this message | ||
Actually, from what I understand, with the persistent connection, it is
left open even after the script is finished - that's why it's called
persistent.
Jeff, (Not Jim :) - it's getting way late for my tired eyes :) Sorry.
Thanks. I suppose I had to read it one more time.
That at least makes sense. I was getting errors like can't find localhost on web
pages dynamically displaying data from a db. Imagine what was happening with
multiple persistent connections jamming up my poor pentium's memory. Mysql was
freaking.
I would have to come into the office at midnight to restart the server.
When I did, I would find errors of persistent connections jamming up my memory
causing people not to be able to use pages. I simply changed mysql_pconnect for
mysql_connect and I'm ready to go home :)
A fresh restart of the server and a few tests later, I think everything is going
to be all right until the ext problem :)
John
> >Thanks. What I don't really get is what persistent means.
> >A problem I'm having with my mysql server is that it is a whole bunch of
> >messages with in the space of 5 minutes like:
> >
> >020130 16:11:08 C:\PROGRA~1\EASYPHP\MySql\bin\mysqld.exe: Forcing close of
> >thread 3 user: 'root'
> >
> >All I have to do is reload the same page a dozen times.
> >
> >To test out the whole thing I'm replacing all my mysql_pconnect for
> >mysql_connect and adding mysql_close to force a closure of the connection.
> >Scripts just didn't seem to be closing. Hence the question. It's supposed
> >to be
> >persistent only until the script finishes, but I can prove otherwise. A
> >windows
> >thing? Who knows?
> >
> >John
>
> Actually, from what I understand, with the persistent connection, it is
> left open even after the script is finished - that's why it's called
> persistent. Read this excerpt from the link I sent you:
>
> mysql_pconnect() acts very much like mysql_connect() with two major
> differences.
> First, when connecting, the function would first try to find a (persistent)
> link that's already open with the same host, username and password. If one
> is found, an identifier for it will be returned instead of opening a new
> connection.
> Second, the connection to the SQL server will not be closed when the
> execution of the script ends. Instead, the link will remain open for future
> use (mysql_close() will not close links established by mysql_pconnect()).
> This type of link is therefore called 'persistent'.
> Note: Note, that these kind of links only work if you are using a module
> version of PHP. See the Persistent Database Connections section for more
> information.
>
> -Jeff (not Jim)