Пример #1
0
 public function __get($collection)
 {
     if (empty($this->_config[$collection])) {
         $this->_config = Data::pushRight($this->_config);
         if (empty($this->_config[$collection])) {
             throw new Exception("collection \"{$collection}\" not defined");
         }
     }
     $config = $this->_config[$collection];
     if (empty($this->_cachedConnections[$config['url']])) {
         $this->_cachedConnections[$collection] = isset($config['options']) ? new MongoClient($config['url'], $config['options']) : new MongoClient($config['url']);
     }
     $db = $this->_cachedConnections[$collection]->selectDB($config['database']);
     $this->_currentCollection = $db->selectCollection($collection);
     return $this;
 }
Пример #2
0
 public function testPushRight()
 {
     $input = ['key', 'key2' => 1, 'key3' => 2];
     $this->assertSame(Data::pushRight($input), ['key' => 1, 'key2' => 1, 'key3' => 2]);
 }