Doctrine\MongoDB\Query\Expr::addManyToSet PHP Method

addManyToSet() public method

If the field does not exist, it will be set to an array containing the unique values in the argument. If the field is not an array, the query will yield an error.
See also: Builder::addManyToSet()
See also: http://docs.mongodb.org/manual/reference/operator/addToSet/
See also: http://docs.mongodb.org/manual/reference/operator/each/
Deprecation: 1.1 Use {@link Expr::addToSet()} with {@link Expr::each()}; Will be removed in 2.0
public addManyToSet ( array $values )
$values array
    public function addManyToSet(array $values)
    {
        $this->requiresCurrentField();
        $this->newObj['$addToSet'][$this->currentField] = ['$each' => $values];
        return $this;
    }

Usage Example

Example #1
0
 /**
  * Append multiple values to the current array field only if they do not
  * already exist in the array.
  *
  * If the field does not exist, it will be set to an array containing the
  * unique values in the argument. If the field is not an array, the query
  * will yield an error.
  *
  * @deprecated 1.1 Use {@link Builder::addToSet()} with {@link Expr::each()}; Will be removed in 2.0
  * @see Expr::addManyToSet()
  * @see http://docs.mongodb.org/manual/reference/operator/addToSet/
  * @see http://docs.mongodb.org/manual/reference/operator/each/
  * @param array $values
  * @return self
  */
 public function addManyToSet(array $values)
 {
     $this->expr->addManyToSet($values);
     return $this;
 }