Commit 400bcaa1 authored by Tim Steiner's avatar Tim Steiner
Browse files

Adding singleton support to Zend_Db_Table via Unl_Db_Table_Abstract

parent 5673c54d
<?php
/**
* Extend the Zend_Db_Table to add the singleton pattern.
*/
abstract class Unl_Db_Table_Abstract extends Zend_Db_Table_Abstract
{
/**
* Storage for the instances of each subclassed table.
* @var array
*/
static protected $_instances = array();
/**
* Returns the singleton instance of the called class.
* @return Unl_Db_Table_Abstract
*/
static public function getInstance()
{
$class = get_called_class();
if (!isset(self::$_instances[$class])) {
self::$_instances[$class] = new $class();
}
return self::$_instances[$class];
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment