public function getClient() {
		if ($this->client === null) {
			$connectionString  = $this->getConnectionString();
			$connectionOptions = $this->getConnectionOptions();

			if ($this->_profilerEnabled) {
				$event = $this->getProfiler()->startInfo('Connect: ' . $connectionString);
			}

			$attempts = $this->connectionAttempts;

			do {
				try {
					$this->client = new MongoClient($connectionString, $connectionOptions);
				}
				catch (MongoConnectionException $exception) {
					sleep($this->connectionTimeout);
				}
				catch (Exception $exception) {
					if ($this->_profilerEnabled) {
						$event->stopError();
					}
				}
			} while ($this->client === null && -- $attempts > 0);

			if ($this->client === null) {
				if ($this->_profilerEnabled) {
					$event->stopError();
				}

				if (isset($exception)) {
					throw new Exceptions\ConnectionError('Unable to connect to the database', $exception->getCode(), $exception);
				} else {
					$exception = new Exceptions\ConnectionError('Unable to connect to the database, after ' . $this->connectionAttempts . ' attempts');
				}

				throw $exception;
			}

			if ($this->_profilerEnabled) {
				if (isset($exception)) {
					$event->stopNotice();
				} else {
					$event->stopSuccess();
				}

				$this->putDetailInfoIntoProfiler();
			}
		}

		return $this->client;
	}
public function getClient() {
		if ($this->client === null) {
			$connectionString  = $this->getConnectionString();
			$connectionOptions = $this->getConnectionOptions();

			if ($this->_profilerEnabled) {
				$event = $this->getProfiler()->startInfo('Connect: ' . $connectionString);
			}

			$attempts = $this->connectionAttempts;

			do {
				try {
					$this->client = new MongoClient($connectionString, $connectionOptions);
				}
				catch (MongoConnectionException $exception) {
					sleep($this->connectionTimeout);
				}
				catch (Exception $exception) {
					if ($this->_profilerEnabled) {
						$event->stopError();
					}
				}
			} while ($this->client === null && -- $attempts > 0);

			if ($this->client === null) {
				if ($this->_profilerEnabled) {
					$event->stopError();
				}

				if (isset($exception)) {
					throw new Exceptions\ConnectionError('Unable to connect to the database', $exception->getCode(), $exception);
				} else {
					$exception = new Exceptions\ConnectionError('Unable to connect to the database, after ' . $this->connectionAttempts . ' attempts');
				}

				throw $exception;
			}

			if ($this->_profilerEnabled) {
				if (isset($exception)) {
					$event->stopNotice();
				} else {
					$event->stopSuccess();
				}

				$this->putDetailInfoIntoProfiler();
			}
		}

		return $this->client;
	}
public function getClient ( ) { if ( $ this -> client === null ) { $ connectionString = $ this -> getConnectionString ( ) ; $ connectionOptions = $ this -> getConnectionOptions ( ) ; if ( $ this -> _profilerEnabled ) { $ event = $ this -> getProfiler ( ) -> startInfo ( 'Connect: ' . $ connectionString ) ; } $ attempts = $ this -> connectionAttempts ; do { try { $ this -> client = new MongoClient ( $ connectionString , $ connectionOptions ) ; } catch ( MongoConnectionException $ exception ) { sleep ( $ this -> connectionTimeout ) ; } catch ( Exception $ exception ) { if ( $ this -> _profilerEnabled ) { $ event -> stopError ( ) ; } } } while ( $ this -> client === null && -- $ attempts > 0 ) ; if ( $ this -> client === null ) { if ( $ this -> _profilerEnabled ) { $ event -> stopError ( ) ; } if ( isset ( $ exception ) ) { throw new Exceptions \ ConnectionError ( 'Unable to connect to the database' , $ exception -> getCode ( ) , $ exception ) ; } else { $ exception = new Exceptions \ ConnectionError ( 'Unable to connect to the database, after ' . $ this -> connectionAttempts . ' attempts' ) ; } throw $ exception ; } if ( $ this -> _profilerEnabled ) { if ( isset ( $ exception ) ) { $ event -> stopNotice ( ) ; } else { $ event -> stopSuccess ( ) ; } $ this -> putDetailInfoIntoProfiler ( ) ; } } return $ this -> client ; }
Get the mongo client

@return MongoClient
@throws Exceptions\ConnectionError
Get the mongo client