Normally, a good googling session would suffice to answer most of my questions, but $this
isn't one of them. Thus, it's is my first question here :
A lot of people (at SO and elsewhere) say that Singletton is bad. Actually so bad that some fellow developers even consider it as an Anti-Christ Anti-Pattern and should be replaced by Dependency Injection Pattern. The only exception to this 'rule' is with loggers (well, almost).
Some argue that because in PHP variables are at most 1 request-old ...
[...] one of the two main purposes of a Singleton is not applicable here.
But during that one request, multiple fetches from the Database may/will occur. Database is a shared resource between ALL the requests and if I don't make sure that there's as few connections as possible, I may get struck with a max_connections
error (just an example).
So, if Singleton is a bad design in most cases, what about managing Database connections ? Is Singleton a good idea or I should opt for DI ?
Thanks in advance : )