Пример #1
0
 /**
  * Return the default Zend\Db\Adapter for this class
  *
  * @throws ConfigException
  * @return Adapter
  */
 protected static function getDefaultDb()
 {
     // Use subclass default db (set via MySubClass::setDefaultDb())
     $calledClass = get_called_class();
     if (isset(self::$_subclassDefaultDb[$calledClass]) && self::$_subclassDefaultDb[$calledClass]) {
         return self::$_subclassDefaultDb[$calledClass];
     }
     // Use superclass default db
     if (static::$_classDefaultDb) {
         return static::$_classDefaultDb;
     }
     // Use global ActiveRecord default db
     if ($db = ZendDb::getGlobalDefaultDb()) {
         return $db;
     }
     throw new ConfigException('Please configure a Zend\\Db\\Adapter instance to use with ActiveRecord.');
 }