Forums
This topic is locked
mysql_pconnect or mysql_connect
Posted 23 Jan 2005 22:20:35
1
has voted
23 Jan 2005 22:20:35 chris caspell posted:
I've been using DWMX2004 for a while but recently my site has been coming up with the error "Warning: too many connections..." I did a bit of investigation and it seems that the connection to the database uses a persistant connection as default (mysql_pconnect). This appears to leave the database open as I can't seen any mysql_close($xxx) entry in the code.I have changed my connection to the simple mysql_connect command which seems to work ok, but does anyone know whether I am correct in my belief that the database connections are not closed under "normal DWMX2004 conditions". Is there a flag in DWMX2004 that can be switched to make it use the non-persistant option? Am I talking rubbish and the database connections ARE closed but I just can't find them?
Thanks in advance for any advice.
Replies
Replied 24 Jan 2005 08:35:02
24 Jan 2005 08:35:02 Chris Charlton replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>...This appears to leave the database open as I can't seen any mysql_close($xxx) entry in the code...<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
You sure? The close code should be after the end of your </html> tag.
It is to my knowledge that MySQL servers close connections from PHP requests by default after processing, so (not sure) it might close anyway.
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>...Is there a flag in DWMX2004 that can be switched to make it use the non-persistant option?...<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I'm not sure about MM default PHP_MySQL <i>Server Model</i>, but I think InterAKTs' PHP <i>Server Models</i> (PHP_ADODB) NeXTensio, ImpAKT, and maybe PhAKT have that option, as to my knowledge.
You sure? The close code should be after the end of your </html> tag.
It is to my knowledge that MySQL servers close connections from PHP requests by default after processing, so (not sure) it might close anyway.
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>...Is there a flag in DWMX2004 that can be switched to make it use the non-persistant option?...<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I'm not sure about MM default PHP_MySQL <i>Server Model</i>, but I think InterAKTs' PHP <i>Server Models</i> (PHP_ADODB) NeXTensio, ImpAKT, and maybe PhAKT have that option, as to my knowledge.
Replied 24 Jan 2005 08:50:45
24 Jan 2005 08:50:45 chris caspell replied:
Thanks for coming back Chris. There isn't a mysql_close at the end of the script, but it does add mysql_free_result. Looking at the PHP manual it says that this "will free all memory associated with the result identifier". Now does this mean that it closes connections or just reinitiates variables? I don't know.
The normal mysql_connect does close connections but mysql_pconnect is supposed to leave them open - thus speeding things up. I would be interested if anyone else has experience with this and in particular if mysql_free_result($recordset) will close the connection.
I am not using phAKT so I can't comment on it.
The normal mysql_connect does close connections but mysql_pconnect is supposed to leave them open - thus speeding things up. I would be interested if anyone else has experience with this and in particular if mysql_free_result($recordset) will close the connection.
I am not using phAKT so I can't comment on it.
Replied 26 Apr 2005 04:30:22
26 Apr 2005 04:30:22 Chris Charlton replied:
Yup, you got it right...
<pre id=code><font face=courier size=2 id=code>mysql_free_result($recordset)</font id=code></pre id=code>
~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>
<pre id=code><font face=courier size=2 id=code>mysql_free_result($recordset)</font id=code></pre id=code>
~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>