When and how often to start connection to database in php?

Posted by AndHeiberg on Server Fault See other posts from Server Fault or by AndHeiberg
Published on 2012-09-17T09:09:05Z Indexed on 2012/09/17 9:39 UTC
Read the original article Hit count: 186

Filed under:
|
|
|

When and how often is it good practice to start the connection to your database in php?

I'm new to databases, and I'm wondering when I should start by database connection. I'm creating a api with an index, controllers and model. Should I start the connection in the index and then pass it to all the other files, start the connection at the top of all files and call it as a global in functions as needed or start and end the connection in every function?

© Server Fault or respective owner

Related posts about mysql

Related posts about php