public function addUpdate($condition, $document, $options = [])
    {
        $options = array_merge(
            [
                'multi' => true,
                'upsert' => false,
            ],
            $options
        );

        if ($options['multi']) {
            $keys = array_keys($document);
            if (!empty($keys) && strncmp('$', $keys[0], 1) !== 0) {
                $document = ['$set' => $document];
            }
        }

        $this->document[] = [
            'type' => 'update',
            'condition' => $this->db->getQueryBuilder()->buildCondition($condition),
            'document' => $document,
            'options' => $options,
        ];
        return $this;
    }
public function addUpdate($condition, $document, $options = [])
    {
        $options = array_merge(
            [
                'multi' => true,
                'upsert' => false,
            ],
            $options
        );

        if ($options['multi']) {
            $keys = array_keys($document);
            if (!empty($keys) && strncmp('$', $keys[0], 1) !== 0) {
                $document = ['$set' => $document];
            }
        }

        $this->document[] = [
            'type' => 'update',
            'condition' => $this->db->getQueryBuilder()->buildCondition($condition),
            'document' => $document,
            'options' => $options,
        ];
        return $this;
    }
public function addUpdate ( $ condition , $ document , $ options = [ ] ) { $ options = array_merge ( [ 'multi' => true , 'upsert' => false , ] , $ options ) ; if ( $ options [ 'multi' ] ) { $ keys = array_keys ( $ document ) ; if ( ! empty ( $ keys ) && strncmp ( '$' , $ keys [ 0 ] , 1 ) !== 0 ) { $ document = [ '$set' => $ document ] ; } } $ this -> document [ ] = [ 'type' => 'update' , 'condition' => $ this -> db -> getQueryBuilder ( ) -> buildCondition ( $ condition ) , 'document' => $ document , 'options' => $ options , ] ; return $ this ; }
Adds the update operation to the batch command.
@param array $condition filter condition
@param array $document data to be updated
@param array $options update options.
@return $this self reference.
@see executeBatch()
Adds the update operation to the batch command .