/** * Returns edmsMongo connection instance if not exists will create new * * @return edmsMongo * @throws EMongoException * @since v1.0 */ public function getMongo() { if (!isset(self::$_mongo)) { try { if (empty($this->dbName)) { throw new EDMSException('No database configured'); } //remove keys with null values $options = array(); foreach ($this->options as $key => $value) { if (isset($value)) { $options[$key] = $value; } } if (!isset($this->server)) { $this->server = 'mongodb://localhost:27017'; } self::$_mongo = new Mongo($this->server, $options); } catch (MongoConnectionException $e) { throw new EDMSException('Failed to create class edmsMongo: ' . $e->getMessage()); } } return self::$_mongo; }
/** * EDMSBehavior::edmsGetDbName() * * @param mixed $connectionId * @return */ public function edmsSetDbName($dbName, $connectionId = null) { $this->edmsSetConnectionId($connectionId); if (!empty($dbName) && $this->edmsGetDbName() != $dbName) { EDMSConnection::instance($this->edmsGetConnectionId())->dbName = $dbName; } }