Beispiel #1
0
 /**
  * Initializer
  * @param Array $options Connection Options
  */
 public function __construct($server = 'mongodb://localhost:27017', array $options = array())
 {
     // Link timeouts
     Cursor::$timeout = \MongoCursor::$timeout;
     \MongoCursor::$timeout =& Cursor::$timeout;
     // Parse MongoDB Path Info
     if (!empty($options['db'])) {
         $db_name = $options['db'];
     } else {
         $uri = parse_url($server);
         $db_name = isset($uri['path']) ? substr($uri['path'], 1) : 'test';
     }
     // Apply defaults
     if (!isset($options['connect'])) {
         $options['connect'] = true;
     }
     // Native connection
     $this->native = new \MongoClient($server, $options);
     // Select Database for default reference
     if ($db_name) {
         $this->selectDb($db_name);
     }
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function timeout($ms)
 {
     $this->cursor->timeout($ms);
     return $this;
 }