02-06-2008, 03:37 PM
|
#28 (permalink)
|
|
The Addict
Join Date: Jan 2008
Location: USA
Posts: 217
Thanks: 16
|
Been a little while, but here's my last five lines. Turning a database class into a singleton factory capable of self-initialization and global-less connection abilities. I didn't count the tidy line that I wrapped as two though, so it's still five lines.
PHP Code:
public static function getInstance() { if(self::$pInstance == null) { self::$pInstance = new Database(); self::$pInstance->connect(Config::get('db_host'), Config::get('db_user'), Config::get('db_pass')) ->selectDB(Config::get('db_name')); } return self::$pInstance;
__________________
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning. - Rich Cook
|
|
|
|