+ 1

How to close mysql connection in PHP with OOP?

I am creating all functions on a page and calling them from another page according to what parameter I received with $_GET. Creating connections like this. https://code.sololearn.com/wDWRgtc7gjT8/#php Wrote class with functions like this https://code.sololearn.com/wTHPR6jC6lBE/#php Calling functions like this. https://code.sololearn.com/wiiK9603z3uk/#php So, how should I close the connection in this? Calling $this->db->close(); at end of every function ?

31st Dec 2021, 5:21 AM
Manjit Kumar
Manjit Kumar - avatar
1 Answer
0
hi, I'm not into PHP but I've noticed that PHP devs usually recommend following the approaches from this ebook, where they explain best practices. there is a whole section about interacting with databases so I hope this helps: https://phptherightway.com/#databases_interacting
6th Jan 2022, 8:53 AM
Doooms
Doooms - avatar