DEV Community

Discussion on: PDO usage

Collapse
 
sebastianr1982 profile image
Sebastian Rapetti • Edited

I prefer make a global PDO, like for your first option. Create a connection for every query is a waste of resources.

For management, if the connection isn't set as persistent, will be closed at the end of the script.

You can check official PDO PHP documentation.

Collapse
 
pbouillon profile image
Pierre Bouillon

Thanks for your answer, it's very helpful !