Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2007
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Must one close a MySQL database?

    I've got a little PHP/MySQL learning project where I'm simply storing links to sites, for display. One page shows the categories to choose from, and when the user makes a choice we jump to the next page which does a query on the category and displays all matching links.

    People will be going back and forth between the two pages, which makes me want to open the database and table once and leave it open. The alternative is repeated opening/closing.. which must introduce quite a bit of overhead.

    The problem is if the user simply leaves either page, which they presumably will at some point, the database will never be closed via an actual close statement.

    What happens in a case like that? In my testing I can't find any downside to doing this, but I suspect there must be one.

    Thanks,
    Bob
    Think slow, type fats

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    when your script exits then the database connection is closed by default.
    You should also look into using persistant connections if you have not done so. that is in the php manual.

  • #3
    New Coder
    Join Date
    Mar 2007
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by guelphdad View Post
    when your script exits then the database connection is closed by default.
    You should also look into using persistant connections if you have not done so. that is in the php manual.
    Thanks.. will check out the persistent connections. Appreciate the reply!
    Think slow, type fats


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •