Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6710869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:04:21+00:00 2026-05-26T08:04:21+00:00

I have website which uses database, I have implemented singleton pattern to connect to

  • 0

I have website which uses database, I have implemented singleton pattern to connect to the database.

But my website uses lots of Iframe or inner pages which in turn connects to database using a singleton pattern in each page.

I have few questions to be clarified
1)if a user A comes to website, he browses 10 pages, does that for all the pages only one connection is created or for every page one connection is created?

2)For all the DB connections amde in the sub pages will use the same connection or a new one ?

3)When the user exists from the website, how to close the DB Connection?
I am finding tricky to close the DB Connection, Suppose in my index.php, if it has menu.php, stats.php and profile.php, I am not able to make out when to close the connection?
What is the best pratice to close the connection?

Website is build on PHP and MYSQL database.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:04:22+00:00Added an answer on May 26, 2026 at 8:04 am

    If you use a singleton, then the connection is established once for every request.

    • For every of the 10 pages.
    • If you include your sub pages via iframes, then you’re opening a new connection for every sub page.
    • One option would be to have a single entry point for your webpage (a front controller) and then closing the connection, after the request has been handled. If you include your php pages in your index.php file, then close the connection after the include/require statements.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website which uses PHP and HTML pages, I want to create
I have a website which uses jQuery and lots of mouseover / mouseout effects.
I have an ASP.Net website which uses a MySQL database for the back end.
I have developed a website using Asp.Net MVC which uses a SQL CE database
I have a website built in asp.net mvc 3 which uses the repository pattern
I have a web site which uses one SQL database but the hosting company
I have a website which uses the custom 404 error handling in PHP/Apache to
I have a website which uses TinyMCE textboxes for editing. It works fine except
I have a website which uses Spring Security. I have realized that when I
I have a Silverlight web app which uses ASP.net Website administration tool for user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.