public function connect() {
		$server = $this->_classes['server'];

		if ($this->server && $this->server->getConnections() && $this->connection) {
			return $this->_isConnected = true;
		}
		$this->_isConnected = false;

		$options = [
			'connect' => true,
			'connectTimeoutMS' => $this->_config['timeout'],
			'replicaSet' => $this->_config['replicaSet'],
		];

		try {
			$this->server = new $server($this->_config['dsn'], $options);

			if ($prefs = $this->_config['readPreference']) {
				$prefs = !is_array($prefs) ? [$prefs, []] : $prefs;
				$this->server->setReadPreference($prefs[0], $prefs[1]);
			}

			if ($this->connection = $this->server->{$this->_config['database']}) {
				$this->_isConnected = true;
			}
		} catch (Exception $e) {
			throw new NetworkException("Could not connect to the database.", 503, $e);
		}
		return $this->_isConnected;
	}
public function connect() {
		$server = $this->_classes['server'];

		if ($this->server && $this->server->getConnections() && $this->connection) {
			return $this->_isConnected = true;
		}
		$this->_isConnected = false;

		$options = [
			'connect' => true,
			'connectTimeoutMS' => $this->_config['timeout'],
			'replicaSet' => $this->_config['replicaSet'],
		];

		try {
			$this->server = new $server($this->_config['dsn'], $options);

			if ($prefs = $this->_config['readPreference']) {
				$prefs = !is_array($prefs) ? [$prefs, []] : $prefs;
				$this->server->setReadPreference($prefs[0], $prefs[1]);
			}

			if ($this->connection = $this->server->{$this->_config['database']}) {
				$this->_isConnected = true;
			}
		} catch (Exception $e) {
			throw new NetworkException("Could not connect to the database.", 503, $e);
		}
		return $this->_isConnected;
	}
public function connect ( ) { $ server = $ this -> _classes [ 'server' ] ; if ( $ this -> server && $ this -> server -> getConnections ( ) && $ this -> connection ) { return $ this -> _isConnected = true ; } $ this -> _isConnected = false ; $ options = [ 'connect' => true , 'connectTimeoutMS' => $ this -> _config [ 'timeout' ] , 'replicaSet' => $ this -> _config [ 'replicaSet' ] , ] ; try { $ this -> server = new $ server ( $ this -> _config [ 'dsn' ] , $ options ) ; if ( $ prefs = $ this -> _config [ 'readPreference' ] ) { $ prefs = ! is_array ( $ prefs ) ? [ $ prefs , [ ] ] : $ prefs ; $ this -> server -> setReadPreference ( $ prefs [ 0 ] , $ prefs [ 1 ] ) ; } if ( $ this -> connection = $ this -> server -> { $ this -> _config [ 'database' ] } ) { $ this -> _isConnected = true ; } } catch ( Exception $ e ) { throw new NetworkException ( "Could not connect to the database." , 503 , $ e ) ; } return $ this -> _isConnected ; }
Connects to the Mongo server. Matches up parameters from the constructor to create a Mongo
database connection.

@see lithium\data\source\MongoDb::__construct()
@link http://php.net/mongo.construct.php PHP Manual: Mongo::__construct()
@return boolean Returns `true` the connection attempt was successful, otherwise `false`.
Connects to the Mongo server . Matches up parameters from the constructor to create a Mongo database connection .