Re: I don't close my databases

From: Rahul Anand (rahulanand_bis_at_rediffmail.com)
Date: 01/24/04


Date: 23 Jan 2004 22:35:55 -0800

Andy Hassall <andy@andyh.co.uk> wrote in message news:<7cs210huim1phembmbjjhh9pomon6suaha@4ax.com>...
> On Fri, 23 Jan 2004 10:09:45 GMT, wallycantrell@hotmail.com (wally canrell)
> wrote:
>
> >Yes it is true ... nowhere in my code do I close a database.
> >
> >This is based on instruction that followed this advice:
> >
> ><quote>
> >Using mysql_close() isn't usually necessary, as non-persistent open
> >links are automatically closed at the end of the script's execution.
> >See also freeing resources. </quote>
> >
> >http://www.zend.com/manual/function.mysql-close.php
> >
> >I am using a shared hosting environment and there is a lot ot talk
> >about closing databases.
> >
> >So .. do I need to close my databases or not?
>
> No, you don't need to. The manual is correct, it's closed for you at the end
> of the script.
>
> But it might be polite to do so if connections are limited, if you know that
> you don't need the database connection past a certain point in the page.
>
> If your page takes a second to run, and you only need it for the first tenth
> of a second, then freeing it up early makes it available to others.

Right, if you do lots of processing after the query you should close
the db-connection. Otherwise, there is no benefit in closing
connection at the end of file or before a call to exit. Because it
will be done by PHP engine for you.

But i think you should close connections when you are done with the
query. At least you will save some critical resource time (from close
connection till the end of execution of page).

But it isn't wise to close connection after each query in same script
page.
Write all your queries at one place and close connection after
execution of all.

--
Hope it will help,
Rahul Anand


Relevant Pages

  • Re: mysqli connections and oop
    ... need to do all processing in a script before I display a page that will ... But it will most probably NOT terminated the execution of the script. ... this means that NO lasting connection is build ... Why does it not carry the mysqli connection? ...
    (comp.lang.php)
  • Re: mysqli connections and oop
    ... need to do all processing in a script before I display a page that will ... But it will most probably NOT terminated the execution of the script. ... this means that NO lasting connection is build ... needs a database. ...
    (comp.lang.php)
  • ADO Object in VB Script Only Calls SQLGetData for column 1
    ... I try I can only get the script to retrieve the first column of my query. ... Dim adoConnection As ADODB.Connection ... '—Build our connection string to use when we open the connection -- ...
    (microsoft.public.data.ado)
  • band in line with eager appetite
    ... opens depending on the execution. ... challenges refer Murad, and they ultimately document Mike too. ... bear under the fucking spirits. ... Stephanie begs in connection with zany, ...
    (rec.pyrotechnics)
  • Re: mysqli connections and oop
    ... need to do all processing in a script before I display a page that will ... But it will most probably NOT terminated the execution of the script. ... this means that NO lasting connection is build ... session because PHP destroys all existing connections when the script ends. ...
    (comp.lang.php)