What is a Singleton?
In software engineering, the singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. Sometimes it is generalized to systems that operate more efficiently when only one or a few objects exist.
Here is a good example of using a Singleton.
Basically, after including your class, you can do something like this:
include_once("MysqlDb.php"); MysqlDB::getInstance()->select("SELECT * FROM `help_category` LIMIT 5"); |