I've came across a problem in an application I am building and that is: how can I create a single database connection for use across multiple classes?
After reading upon this a little bit, different posts/people seem to be telling me different things. Use of $_GLOBAL
or the global
keyword would be one way to do it, but that has it's own issues.
Other threads on Stackoverflow have suggested Singletons
as a way of doing so, but also stated that it wouldn't be the proper way of achieving a shared property of an instance.
So, what would be the best way of achieving this, say for a Database Controller or a Session Controller?