getName() public method

Returns this collection's name
public getName ( ) : string
return string
Esempio n. 1
0
 /**
  * @see QueueInterface::pop()
  */
 public function pop()
 {
     $command = array('findandmodify' => $this->collection->getName(), 'remove' => 1, 'fields' => array('task' => 1), 'query' => array('eta' => array('$lte' => new \MongoDate())), 'sort' => array('eta' => 1));
     $result = $this->collection->db->command($command);
     if (!$result['ok']) {
         throw new \RuntimeException($result['errmsg']);
     }
     $data = $result['value'];
     return $data ? $this->serializer->unserialize($data['task']) : false;
 }
Esempio n. 2
0
 /**
  * Indicate that the table needs to be created.
  *
  * @return bool
  */
 public function create()
 {
     $collection = $this->collection->getName();
     $db = $this->connection->getMongoDB();
     // Ensure the collection is created.
     $db->createCollection($collection);
 }
 public function generateId(MongoCollection $collection)
 {
     $collection_name = $collection->getName();
     $document = $this->collection->findAndModify(array('_id' => $collection_name), array('$inc' => array('_max_id' => 1)), null, array('new' => true));
     if (!$document) {
         $this->collection->insert(array('_id' => $collection_name, '_max_id' => $this->autoIncrement));
         return $this->generateId($collection);
     }
     return $document['_max_id'];
 }
Esempio n. 4
0
 protected function doMapReduce($map, $reduce, array $query, array $options)
 {
     if (is_string($map)) {
         $map = new \MongoCode($map);
     }
     if (is_string($reduce)) {
         $reduce = new \MongoCode($reduce);
     }
     $command = array();
     $command['mapreduce'] = $this->mongoCollection->getName();
     $command['map'] = $map;
     $command['reduce'] = $reduce;
     $command['query'] = $query;
     $command = array_merge($command, $options);
     $result = $this->database->command($command);
     if (!$result['ok']) {
         throw new \RuntimeException($result['errmsg']);
     }
     return $this->database->selectCollection($result['result'])->find();
 }
Esempio n. 5
0
 /**
  * Execute the geoNear command.
  *
  * @see Collection::near()
  * @param array|Point $near
  * @param array       $query
  * @param array       $options
  * @return ArrayIterator
  * @throws ResultException if the command fails
  */
 protected function doNear($near, array $query, array $options)
 {
     $options = isset($options['timeout']) ? $this->convertSocketTimeout($options) : $options;
     if ($near instanceof Point) {
         $near = $near->jsonSerialize();
     }
     $command = array();
     $command['geoNear'] = $this->mongoCollection->getName();
     $command['near'] = $near;
     $command['spherical'] = isset($near['type']);
     $command['query'] = (object) $query;
     $command = array_merge($command, $options);
     $database = $this->database;
     $result = $this->retry(function () use($database, $command) {
         return $database->command($command);
     });
     if (empty($result['ok'])) {
         throw new ResultException($result);
     }
     $arrayIterator = new ArrayIterator(isset($result['results']) ? $result['results'] : array());
     $arrayIterator->setCommandResult($result);
     return $arrayIterator;
 }
Esempio n. 6
0
 /**
  * Generate the unique cache key for the current query.
  *
  * @return string
  */
 public function generateCacheKey()
 {
     $key = array('connection' => $this->connection->getName(), 'collection' => $this->collection->getName(), 'wheres' => $this->wheres, 'columns' => $this->columns, 'groups' => $this->groups, 'orders' => $this->orders, 'offset' => $this->offset, 'aggregate' => $this->aggregate);
     return md5(serialize(array_values($key)));
 }
 public function testGetName()
 {
     $this->assertEquals($this->object->getName(), 'c');
 }
Esempio n. 8
0
 /**
  * Dumps all objects in a collection
  *
  * @param \MongoCollection $collection     collection
  * @param string           $destinationDir destination dir
  *
  * @return void
  */
 private function dumpCollection(\MongoCollection $collection, $destinationDir)
 {
     foreach ($collection->find() as $record) {
         $this->dumpObject($record, $collection->getName(), $destinationDir);
     }
 }
Esempio n. 9
0
 /**
  * Get name of collection
  * 
  * @return string name of collection
  */
 public function getName()
 {
     return $this->_mongoCollection->getName();
 }