/** * Returns the database connection used by active record. * By default, the "mongodb" application component is used as the database connection. * You may override this method if you want to use a different database connection. * @return EMongoClient - the database connection used by active record. * @throws EMongoException */ public function getDbConnection() { if (self::$db !== null) { return self::$db; } self::$db = $this->getMongoComponent(); if (self::$db instanceof EMongoClient) { return self::$db; } throw new EMongoException(Yii::t('yii', 'MongoDB Active Record requires a "mongodb" EMongoClient application component.')); }
/** * Returns the database connection used by active record. * By default, the "mongodb" application component is used as the database connection. * You may override this method if you want to use a different database connection. * @return EMongoClient the database connection used by active record. */ public function getDbConnection() { if (self::$db !== null) { return self::$db; } else { self::$db = Yii::app()->mongodb; if (self::$db instanceof EMongoClient) { return self::$db; } else { throw new EMongoException(Yii::t('yii', 'MongoDB Active Record requires a "mongodb" EMongoClient application component.')); } } }