Example #1
0
 /**
  * Creates a collection
  *
  * @link http://www.php.net/manual/en/mongodb.createcollection.php
  * @param string $name The name of the collection.
  * @param array $options
  * @return MongoCollection Returns a collection object representing the new collection.
  */
 public function createCollection($name, $options)
 {
     try {
         $this->db->createCollection($name, $options);
     } catch (\MongoDB\Driver\Exception\Exception $e) {
         return false;
     }
     return $this->selectCollection($name);
 }
Example #2
0
 /**
  * Creates a collection
  *
  * @link http://www.php.net/manual/en/mongodb.createcollection.php
  * @param string $name The name of the collection.
  * @param array $options
  * @return MongoCollection Returns a collection object representing the new collection.
  */
 public function createCollection($name, $options)
 {
     try {
         if (isset($options['capped'])) {
             $options['capped'] = (bool) $options['capped'];
         }
         $this->db->createCollection($name, $options);
     } catch (\MongoDB\Driver\Exception\Exception $e) {
         return false;
     }
     return $this->selectCollection($name);
 }
Example #3
0
 /**
  * @see Database::createCollection()
  */
 public function createCollection($collectionName, array $options = [])
 {
     $options = array_merge(array('capped' => false, 'size' => 0, 'max' => 0), $options);
     $this->log(array('createCollection' => true, 'name' => $collectionName, 'options' => $options, 'capped' => $options['capped'], 'size' => $options['size'], 'max' => $options['max']));
     return parent::createCollection($collectionName, $options);
 }
Example #4
0
 /**
  * Creates a collection
  * @link http://www.php.net/manual/en/mongodb.createcollection.php
  * @param string $name The name of the collection.
  * @param array $options [optional] <p>
  * <p>
  * An array containing options for the collections. Each option is its own
  * element in the options array, with the option name listed below being
  * the key of the element. The supported options depend on the MongoDB
  * server version. At the moment, the following options are supported:
  * </p>
  * <p>
  * <b>capped</b>
  * <p>
  * If the collection should be a fixed size.
  * </p>
  * </p>
  * <p>
  * <b>size</b>
  * <p>
  * If the collection is fixed size, its size in bytes.</p></p>
  * <p><b>max</b>
  * <p>If the collection is fixed size, the maximum number of elements to store in the collection.</p></p>
  * <i>autoIndexId</i>
  *
  * <p>
  * If capped is <b>TRUE</b> you can specify <b>FALSE</b> to disable the
  * automatic index created on the <em>_id</em> field.
  * Before MongoDB 2.2, the default value for
  * <em>autoIndexId</em> was <b>FALSE</b>.
  * </p>
  * </p>
  * @return MongoCollection <p>Returns a collection object representing the new collection.</p>
  */
 public function createCollection($name, $options)
 {
     $this->db->createCollection($name, $options);
     return $this->selectCollection($name);
 }