Example #1
0
 public function __construct()
 {
     $backendConfiguration = Conf::f('session_mongodb', array());
     foreach ($backendConfiguration as $key => $value) {
         $this->{$key} = $value;
     }
     if ($this->database === null || $this->collection === null) {
         throw new Exception('Configuration missing or invalid for MongoDB Session Backend');
     }
     $this->db = DB::get($this->database)->selectCollection($this->collection);
 }
Example #2
0
 public function __construct()
 {
     $backendConfiguration = Conf::f('session_memcached', array());
     foreach ($backendConfiguration as $key => $value) {
         $this->{$key} = $value;
     }
     $this->expire = Conf::f('session_cookie_expire', null);
     if ($this->database === null) {
         throw new Exception('Configuration missing or invalid for Memcached Session Backend');
     }
     $this->db = DB::get($this->database);
 }
 public function testIteratorFile()
 {
     $db = DB::get('default');
     $gridfs = $db->getGridFS('gridfsname');
     $data = array('memo_a.txt' => 'bin data very important', 'memo_b.bin' => '12345648913461320564846', 'memo_c.csv' => 'a,c,v,f,f,g,bv,fr,r,f,f');
     foreach ($data as $filename => $content) {
         $gridfs->storeBytes($content, array('filename' => $filename));
     }
     $i = 0;
     $it = new FileIterator('gridfsname');
     foreach ($it as $file) {
         $filename = $file->getFilename();
         $content = $file->getBytes();
         $this->assertEquals($content, $data[$filename]);
         $i++;
     }
     $this->assertEquals($i, 3);
 }
Example #4
0
 public static function isEmpty()
 {
     $config = Conf::f('storage-mongodb-object', array());
     $db = isset($config['databases']) ? $config['databases'] : 'default';
     $db = DB::get($db);
     $collection = $db->selectCollection($this->getCollectionName());
     $it = $collection->find();
     $it->limit(1);
     $it->rewind();
     return $it->hasNext() === false;
 }
Example #5
0
 public static function inc($id)
 {
     $db = Connection::get(static::database);
     $obj = $db->command(array('findandmodify' => static::collection, 'query' => array('_id' => $id), 'update' => array('$inc' => array('c' => 1)), 'upsert' => 1, 'new' => 1));
     return $obj['value']['c'];
 }