PHP Class League\Monga\Query\Update

Inheritance: extends League\Monga\Query\Where
Show file Open project: php-loep/monga Class Usage Examples

Protected Properties

Property Type Description
$atomic boolean whether to use atomic mode
$multiple boolean whether to update multiple or only one
$update array @update update query
$upsert boolean whether to allow upserts

Public Methods

Method Description
addToSet ( string $field, mixed $value ) : object Adds the values to the set or upsert when the dataset doesn't contain them already
atomic ( boolean $atomic = true ) : object Set the multiple option.
getOptions ( ) : array Returns the query options
getUpdate ( ) : array Returns the formatted update query.
increment ( string $field, integer $by = 1 ) : object Increments a field value.
multiple ( boolean $multiple = true ) : object Set the multiple option.
pop ( string $field ) : object Removes an item off the ending of a field array.
pull ( string $field, string $value, string $operator = null, boolean $all = false ) : object Removes all matched instances from a field array
pullAll ( string $field, string $value, string $operator = null ) : object Removes all matched instances from a field array
push ( string $field, mixed $value, boolean $all = false ) : object Pushes a value onto a field array
pushAll ( string $field, array $values ) : object Pushes a value onto a field array
remove ( string $field ) : object Removes a field from a document.
rename ( string $field, string $to ) : object Rename a field.
set ( string $field, string $value = null ) : object Update the field from a document.
single ( boolean $single = true ) : object Set the multiple option negatively.
unshift ( string $field ) : object Removes an item off the beginning of a field array.
upsert ( boolean $upsert = true ) : object Set the upsert option.

Protected Methods

Method Description
update ( string $type, string $field, mixed $value ) Sets the value of the insert.

Method Details

addToSet() public method

Adds the values to the set or upsert when the dataset doesn't contain them already
public addToSet ( string $field, mixed $value ) : object
$field string field name
$value mixed value to set/upsert with
return object $this

atomic() public method

Set the multiple option.
public atomic ( boolean $atomic = true ) : object
$atomic boolean whether to use atomic more
return object $this

getOptions() public method

Returns the query options
public getOptions ( ) : array
return array query options

getUpdate() public method

Returns the formatted update query.
public getUpdate ( ) : array
return array update query

increment() public method

Increments a field value.
public increment ( string $field, integer $by = 1 ) : object
$field string field to increment
$by integer value to increment by
return object $this

multiple() public method

Set the multiple option.
public multiple ( boolean $multiple = true ) : object
$multiple boolean whether to allow multiple updates
return object $this

pop() public method

Removes an item off the ending of a field array.
public pop ( string $field ) : object
$field string field name
return object $this

pull() public method

Removes all matched instances from a field array
public pull ( string $field, string $value, string $operator = null, boolean $all = false ) : object
$field string field to unshift
$value string values to remove
$operator string condition operator
$all boolean
return object $this

pullAll() public method

Removes all matched instances from a field array
public pullAll ( string $field, string $value, string $operator = null ) : object
$field string field to unshift
$value string values to remove
$operator string condition operator
return object $this

push() public method

Pushes a value onto a field array
public push ( string $field, mixed $value, boolean $all = false ) : object
$field string field name
$value mixed value to append to the array
$all boolean whether to remove all (must be array)
return object $this

pushAll() public method

Pushes a value onto a field array
public pushAll ( string $field, array $values ) : object
$field string field name
$values array value to append to the array
return object $this

remove() public method

Removes a field from a document.
public remove ( string $field ) : object
$field string field to remove
return object $this

rename() public method

Rename a field.
public rename ( string $field, string $to ) : object
$field string field name
$to string new field name
return object $this

set() public method

Update the field from a document.
public set ( string $field, string $value = null ) : object
$field string field name
$value string new value
return object $this

single() public method

Set the multiple option negatively.
public single ( boolean $single = true ) : object
$single boolean whether to allow single updates
return object $this

unshift() public method

Removes an item off the beginning of a field array.
public unshift ( string $field ) : object
$field string field name
return object $this

update() protected method

Sets the value of the insert.
protected update ( string $type, string $field, mixed $value )
$type string update modifier
$field string field to update
$value mixed update value

upsert() public method

Set the upsert option.
public upsert ( boolean $upsert = true ) : object
$upsert boolean whether to allow upserts
return object $this

Property Details

$atomic protected property

whether to use atomic mode
protected bool $atomic
return boolean

$multiple protected property

whether to update multiple or only one
protected bool $multiple
return boolean

$update protected property

@update update query
protected array $update
return array

$upsert protected property

whether to allow upserts
protected bool $upsert
return boolean