/** * Construct * @param string $server Server hostname * @param string $port Port * @throws Exceptions\ConnectionFailException */ function __construct($server = 'localhost', $port = self::PORT) { try { /* @var $MongoDBClient \MongoDB\Client */ $MongoDBClient = new \MongoDB\Client(self::PROTOCOL . $server . ":" . $port, [], ['typeMap' => ['root' => 'array', 'document' => 'array', 'array' => 'array']]); $MongoDBClient->listDatabases(); //info $this->MongoDBClient = $MongoDBClient; } catch (\MongoDB\Driver\Exception\ConnectionTimeoutException $e) { $this->isConnect = false; throw new Exceptions\ConnectionFailException('Error no connect to data base: ' . $e->getMessage()); } catch (\Exception $ex) { $this->isConnect = false; throw new Exceptions\ConnectionFailException('Error no connect to data base: ' . $ex->getMessage()); } }