On 3/31/06, Martin Zvarík <[EMAIL PROTECTED]> wrote:
> Richard Lynch wrote:
>
> >On Fri, March 31, 2006 2:30 pm, Martin Zvarík wrote:
> >
> >
> >>    I was wondering why is it necessary to use mysql_close() at the
> >>end
> >>of your script.
> >>If you don't do it, it works anyways, doesn't it?
> >>
> >>
> >
> >Yes, but...
> >
> >Suppose you write a script to read data from one MySQL server, and
> >then insert it into 200 other MySQL servers, as a sort of home-brew
> >replication (which would be really dumb to do, mind you)...
> >
> >In that case, you REALLY don't want the overhead of all 200
> >connections open, so after you finish each one, you would close it.
> >
> >There are also cases where you finish your MySQL work, but have a TON
> >of other stuff to do in the script, which will not require MySQL.
> >
> >Close the connection to free up the resource, like a good little boy. :-)
> >
> >There also COULD be cases where your PHP script is not ending
> >properly, and you'd be better off to mysql_close() yourself.
> >
> >
> >
> So, does the connection close automatically at the end of the script ?
>
> My situation is following:
>     I have a e-shop with a ridiculously small amount of max approved
> connections, so it gives an error to about 10% of my visitors a day,
> that the mysql connections were exceeded.
>
> Now, if I will delete the "mysql_close()" line, will that help me or
> not? My webhosting does not allow perminent connections either.
>
> Thanks,
> MZ

deleting the mysql_close() line would keep the connection open until
the script ends.
by closing it earlier when you're done with the database for the
"event", your script continues on, ie - parsing/displaying of db query
results, template rendering, etc. yet the connection was closed
earlier so other processes can use mysql (assuming your hitting your
limit this way with too many simultaneous connections).





--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

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

Reply via email to