I'd like to know a better or best way to initialize PDO mysql connection once and use it. I actually implemented singleton design pattern to PDO and it works just fine, I'm happy with it, but anyway I found a lot of discussions going on stackoverflow about singleton design pattern and how bad it really is, that it's anti-pattern, bad for testing and etc... To be honest I don't know other ways to make the same functionality without using singleton and as long as it works I don't care, the project where I'm using singleton pattern is really small and probably will never be extended. Should I really stop using singleton pattern in PHP everywhere? I would be really happy if someone out here could explain me what are alternatives to singleton pattern if I want let's say to keep the same MYSQL connection in whole application.
Aucun commentaire:
Enregistrer un commentaire