/** * Gets and sets the database connection * * If a connection isn't open then this creates the connection, stores it and returns it. * On further calls it return the original connection * @return MongoDB */ private static function getMongoConnection() { $m = new MongoClient(self::getMongoURI()); if (self::$db === null) { self::$db = $m->selectDB(DB_NAME); } return self::$db; }