Ejemplo n.º 1
0
 public static function getInstance($class, AeInterface_Database $database)
 {
     if (!$database->isConnected()) {
         throw new AeOrmModelException('Database connection must be established first', 401);
     }
     if (!is_subclass_of($class, 'AeOrm_Model')) {
         throw new AeOrmModelException('Class must be a subclass of AeOrm_Model', 405);
     }
     static $models = array();
     $key = md5($database->getClass() . $class);
     if (!isset($models[$key])) {
         $models[$key] = new $class($database);
     }
     return $models[$key];
 }