Loans - Secured Loans - 0 Credit Cards - Mortgage Calculator - Pirate Costume

PDA

View Full Version : which one is the best way in connecting-disconnecting to mysql database ?


rajnikant
Feb 13th 2007, 4:39 am
In my application, I opened a non-persistent mysql db connection at the top of the php file and I have closed it at the end of php file. so all db query functions (for ex. query(), getall(), fetchonerow() etc..) will use the same resouce id and perform the tasks.

The other way I came to know is, establish a connection in all db functions first then perform the tasks and the close the opened connection at the end of all db functions.

Which one is more efficient and the best way ?

hamidof
Feb 15th 2007, 5:31 am
One shared connection.

toby
Feb 15th 2007, 7:48 pm
i prefer the open and close within the page itself as users may only request a connection per page basis.