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.