When and how often to start connection to database in php?
- by AndHeiberg
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?