/** * Sets database * * @param string $modelClass * @param int $fetchType One of constants */ public function __construct($modelClass = null, $fetchType = null) { if (static::$_database == null) { static::$_database = $this->_getDatabases(); } parent::__construct($modelClass, $fetchType); }
/** * Sets database. That needs to be performed before you can get any data. * * @param MongoDB|array $database * @return void */ public static function setDatabase($database) { if ($database instanceof \MongoDb) { static::$_database = array('defalut' => $database); } elseif (is_array($database)) { static::$_database = $database; } else { throw new \Exception('Database must be an array fo MongoDb objects or MongoDb object'); } }