public function pushEach($fieldName, array $values)
    {
        $oldValue = $this->get($fieldName);

        if ($this->getId()) {
            if (!$oldValue) {
                $this->operator->pushEach($fieldName, $values);
            } elseif (!is_array($oldValue)) {
                $values = array_merge((array) $oldValue, $values);
                $this->operator->set($fieldName, $values);
            } else {
                $this->operator->pushEach($fieldName, $values);
                $values = array_merge($oldValue, $values);
            }
        } else {
            if ($oldValue) {
                $values = array_merge((array) $oldValue, $values);
            }
        }

        // update local data
        parent::set($fieldName, $values);

        return $this;
    }
public function pushEach($fieldName, array $values)
    {
        $oldValue = $this->get($fieldName);

        if ($this->getId()) {
            if (!$oldValue) {
                $this->operator->pushEach($fieldName, $values);
            } elseif (!is_array($oldValue)) {
                $values = array_merge((array) $oldValue, $values);
                $this->operator->set($fieldName, $values);
            } else {
                $this->operator->pushEach($fieldName, $values);
                $values = array_merge($oldValue, $values);
            }
        } else {
            if ($oldValue) {
                $values = array_merge((array) $oldValue, $values);
            }
        }

        // update local data
        parent::set($fieldName, $values);

        return $this;
    }
public function pushEach ( $ fieldName , array $ values ) { $ oldValue = $ this -> get ( $ fieldName ) ; if ( $ this -> getId ( ) ) { if ( ! $ oldValue ) { $ this -> operator -> pushEach ( $ fieldName , $ values ) ; } elseif ( ! is_array ( $ oldValue ) ) { $ values = array_merge ( ( array ) $ oldValue , $ values ) ; $ this -> operator -> set ( $ fieldName , $ values ) ; } else { $ this -> operator -> pushEach ( $ fieldName , $ values ) ; $ values = array_merge ( $ oldValue , $ values ) ; } } else { if ( $ oldValue ) { $ values = array_merge ( ( array ) $ oldValue , $ values ) ; } } // update local data parent :: set ( $ fieldName , $ values ) ; return $ this ; }
Push each element of argument's array as single element to field value

@param string $fieldName
@param array $values
@return \Sokil\Mongo\Document
Push each element of argument s array as single element to field value