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 ?
i prefer the open and close within the page itself as users may only request a connection per page basis.