Updates one object in collection
@param  string $col Collection's name
@param  array $cond Conditions
@param  array $data Data
@param  callable $cb Optional. Callback
@param  array $params Optional. Parameters
@callback $cb ( )
@return void
328646
public function updateOne($col, $cond, $data, $cb = null, $params = [])
    {
        $this->update($col, $cond, $data, 0, $cb, $params);
    }
1128765
protected function filterStoreCondition($collection, $column)
    {
        if (!($value = $column->getFilter()->getValue())) {
            return;
        }

        $collection->addStoreFilter($value);
    }
631525
public static function batchUpdate(array $columns, $condition)
    {
        $command = static::getDb()->createCommand();
        if (!$command instanceof Command) {
            throw new InvalidConfigException(Yii::t('errors', 'Component Command must be inherited from the class: {class}.', [
                'class' => Command::class
            ]));
        }
        $command->batchUpdate(static::tableName(), $columns, $condition);
        return $command->execute();
    }
883321
protected function sort($data,$cond) {
		$cols=\Base::instance()->split($cond);
		uasort(
			$data,
			function($val1,$val2) use($cols) {
				foreach ($cols as $col) {
					$parts=explode(' ',$col,2);
					$order=empty($parts[1])?
						SORT_ASC:
						constant($parts[1]);
					$col=$parts[0];
					if (!array_key_exists($col,$val1))
						$val1[$col]=NULL;
					if (!array_key_exists($col,$val2))
						$val2[$col]=NULL;
					list($v1,$v2)=[$val1[$col],$val2[$col]];
					if ($out=strnatcmp($v1,$v2)*
						(($order==SORT_ASC)*2-1))
						return $out;
				}
				return 0;
			}
		);
		return $data;
	}
906817
public function update(array $data)
    {
        $this->manager->postPendingQuery(
            new PendingQuery(
                $this->entity,
                PendingQuery::TYPE_UPDATE,
                $this->getUpdateQuery($data),
                $this->parameters
            )
        );
    }
918293
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;


         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(PersonTeamLinkVersionTableMap::ID)) {
            $modifiedColumns[':p' . $index++]  = 'ID';
        }
        if ($this->isColumnModified(PersonTeamLinkVersionTableMap::PERSON_ID)) {
            $modifiedColumns[':p' . $index++]  = 'PERSON_ID';
        }
        if ($this->isColumnModified(PersonTeamLinkVersionTableMap::TEAM_ID)) {
            $modifiedColumns[':p' . $index++]  = 'TEAM_ID';
        }
        if ($this->isColumnModified(PersonTeamLinkVersionTableMap::CREATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'CREATED_AT';
        }
        if ($this->isColumnModified(PersonTeamLinkVersionTableMap::UPDATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'UPDATED_AT';
        }
        if ($this->isColumnModified(PersonTeamLinkVersionTableMap::VERSION)) {
            $modifiedColumns[':p' . $index++]  = 'VERSION';
        }
        if ($this->isColumnModified(PersonTeamLinkVersionTableMap::VERSION_CREATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'VERSION_CREATED_AT';
        }
        if ($this->isColumnModified(PersonTeamLinkVersionTableMap::VERSION_CREATED_BY)) {
            $modifiedColumns[':p' . $index++]  = 'VERSION_CREATED_BY';
        }
        if ($this->isColumnModified(PersonTeamLinkVersionTableMap::PERSON_ID_VERSION)) {
            $modifiedColumns[':p' . $index++]  = 'PERSON_ID_VERSION';
        }
        if ($this->isColumnModified(PersonTeamLinkVersionTableMap::TEAM_ID_VERSION)) {
            $modifiedColumns[':p' . $index++]  = 'TEAM_ID_VERSION';
        }

        $sql = sprintf(
            'INSERT INTO person_team_link_version (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case 'ID':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case 'PERSON_ID':
                        $stmt->bindValue($identifier, $this->person_id, PDO::PARAM_INT);
                        break;
                    case 'TEAM_ID':
                        $stmt->bindValue($identifier, $this->team_id, PDO::PARAM_INT);
                        break;
                    case 'CREATED_AT':
                        $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'UPDATED_AT':
                        $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'VERSION':
                        $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
                        break;
                    case 'VERSION_CREATED_AT':
                        $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'VERSION_CREATED_BY':
                        $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
                        break;
                    case 'PERSON_ID_VERSION':
                        $stmt->bindValue($identifier, $this->person_id_version, PDO::PARAM_INT);
                        break;
                    case 'TEAM_ID_VERSION':
                        $stmt->bindValue($identifier, $this->team_id_version, PDO::PARAM_INT);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        $this->setNew(false);
    }
945422
private function Combine(Condition $cond, $combiner)
    {
        $statement = '(' . $this->statement . ') ' . $combiner . ' (' . $cond->statement . ')';
        return new self($this->connection, $statement);
    }
557696
private function reloadNewsCategoriesWidget(DataContainer $dc)
    {
        /**
         * @var Database
         * @var Input    $input
         */
        $db = $this->framework->createInstance(Database::class);
        $input = $this->framework->getAdapter(Input::class);

        $id = $input->get('id');
        $field = $dc->inputName = $input->post('name');

        // Handle the keys in "edit multiple" mode
        if ('editAll' === $input->get('act')) {
            $id = \preg_replace('/.*_([0-9a-zA-Z]+)$/', '$1', $field);
            $field = \preg_replace('/(.*)_[0-9a-zA-Z]+$/', '$1', $field);
        }

        $dc->field = $field;

        // The field does not exist
        if (!isset($GLOBALS['TL_DCA'][$dc->table]['fields'][$field])) {
            $this->logger->log(
                LogLevel::ERROR,
                \sprintf('Field "%s" does not exist in DCA "%s"', $field, $dc->table),
                ['contao' => new ContaoContext(__METHOD__, TL_ERROR)]
            );

            throw new BadRequestHttpException('Bad request');
        }

        $row = null;
        $value = null;

        // Load the value
        if ('overrideAll' !== $input->get('act') && $id > 0 && $db->tableExists($dc->table)) {
            $row = $db->prepare('SELECT * FROM '.$dc->table.' WHERE id=?')->execute($id);

            // The record does not exist
            if ($row->numRows < 1) {
                $this->logger->log(
                    LogLevel::ERROR,
                    \sprintf('A record with the ID "%s" does not exist in table "%s"', $id, $dc->table),
                    ['contao' => new ContaoContext(__METHOD__, TL_ERROR)]
                );

                throw new BadRequestHttpException('Bad request');
            }

            $value = $row->$field;
            $dc->activeRecord = $row;
        }

        // Call the load_callback
        if (\is_array($GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['load_callback'])) {
            /** @var System $systemAdapter */
            $systemAdapter = $this->framework->getAdapter(System::class);

            foreach ($GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['load_callback'] as $callback) {
                if (\is_array($callback)) {
                    $value = $systemAdapter->importStatic($callback[0])->{$callback[1]}($value, $dc);
                } elseif (\is_callable($callback)) {
                    $value = $callback($value, $dc);
                }
            }
        }

        // Set the new value
        $value = $input->post('value', true);

        // Convert the selected values
        if ($value) {
            /** @var StringUtil $stringUtilAdapter */
            $stringUtilAdapter = $this->framework->getAdapter(StringUtil::class);
            $value = $stringUtilAdapter->trimsplit("\t", $value);
            $value = \serialize($value);
        }

        /** @var NewsCategoriesPickerWidget $strClass */
        $strClass = $GLOBALS['BE_FFL']['newsCategoriesPicker'];

        /** @var NewsCategoriesPickerWidget $objWidget */
        $objWidget = new $strClass($strClass::getAttributesFromDca($GLOBALS['TL_DCA'][$dc->table]['fields'][$field], $dc->inputName, $value, $field, $dc->table, $dc));

        throw new ResponseException(new Response($objWidget->generate()));
    }
1201252
function update($id, $save_cols)
    {
        $updated   = false;
        $write_sql = array();
        $record    = $this->get_record($id, true);
        $save_cols = $this->convert_save_data($save_cols, $record);

        foreach ($save_cols as $col => $value) {
            $write_sql[] = sprintf("%s=%s", $this->db->quote_identifier($col), $this->db->quote($value));
        }

        if (!empty($write_sql)) {
            $this->db->query(
                "UPDATE " . $this->db->table_name($this->db_name, true).
                " SET `changed` = ".$this->db->now().", ".join(', ', $write_sql).
                " WHERE `contact_id` = ?".
                    " AND `user_id` = ?".
                    " AND `del` <> 1",
                $id,
                $this->user_id
            );

            $updated = $this->db->affected_rows();
            $this->result = null;  // clear current result (from get_record())
        }

        return !empty($updated);
    }
1069597
public function update_config(&$data) {
        global $DB;

        if (!empty($data->criteria_activity) && is_array($data->criteria_activity)) {

            $this->course = $data->id;

            // Data comes from advcheckbox, so contains keys for all activities.
            // A value of 0 is 'not checked' whereas 1 is 'checked'.
            foreach ($data->criteria_activity as $activity => $val) {
                // Only update those which are checked.
                if (!empty($val)) {
                    $module = $DB->get_record('course_modules', array('id' => $activity));
                    $this->module = self::get_mod_name($module->module);
                    $this->moduleinstance = $activity;
                    $this->id = null;
                    $this->insert();
                }
            }
        }
    }
449936
function update($id, $save_cols)
    {
        $record = $this->get_record($id, true);

        $newdata     = array();
        $replacedata = array();
        $deletedata  = array();
        $subdata     = array();
        $subdeldata  = array();
        $subnewdata  = array();

        $ldap_data = $this->_map_data($save_cols);
        $old_data  = $record['_raw_attrib'];

        // special handling of photo col
        if ($photo_fld = $this->fieldmap['photo']) {
            // undefined means keep old photo
            if (!array_key_exists('photo', $save_cols)) {
                $ldap_data[$photo_fld] = $record['photo'];
            }
        }

        foreach ($this->fieldmap as $fld) {
            if ($fld) {
                $val = $ldap_data[$fld];
                $old = $old_data[$fld];
                // remove empty array values
                if (is_array($val))
                    $val = array_filter($val);
                // $this->_map_data() result and _raw_attrib use different format
                // make sure comparing array with one element with a string works as expected
                if (is_array($old) && count($old) == 1 && !is_array($val)) {
                    $old = array_pop($old);
                }
                if (is_array($val) && count($val) == 1 && !is_array($old)) {
                    $val = array_pop($val);
                }
                // Subentries must be handled separately
                if (!empty($this->prop['sub_fields']) && isset($this->prop['sub_fields'][$fld])) {
                    if ($old != $val) {
                        if ($old !== null) {
                            $subdeldata[$fld] = $old;
                        }
                        if ($val) {
                            $subnewdata[$fld] = $val;
                        }
                    }
                    else if ($old !== null) {
                        $subdata[$fld] = $old;
                    }
                    continue;
                }

                // The field does exist compare it to the ldap record.
                if ($old != $val) {
                    // Changed, but find out how.
                    if ($old === null) {
                        // Field was not set prior, need to add it.
                        $newdata[$fld] = $val;
                    }
                    else if ($val == '') {
                        // Field supplied is empty, verify that it is not required.
                        if (!in_array($fld, $this->prop['required_fields'])) {
                            // ...It is not, safe to clear.
                            // #1488420: Workaround "ldap_mod_del(): Modify: Inappropriate matching in..."
                            // jpegPhoto attribute require an array() here. It looks to me that it works for other attribs too
                            $deletedata[$fld] = array();
                            //$deletedata[$fld] = $old_data[$fld];
                        }
                    }
                    else {
                        // The data was modified, save it out.
                        $replacedata[$fld] = $val;
                    }
                } // end if
            } // end if
        } // end foreach

        // console($old_data, $ldap_data, '----', $newdata, $replacedata, $deletedata, '----', $subdata, $subnewdata, $subdeldata);

        $dn = self::dn_decode($id);

        // Update the entry as required.
        if (!empty($deletedata)) {
            // Delete the fields.
            if (!$this->ldap->mod_del($dn, $deletedata)) {
                $this->set_error(self::ERROR_SAVING, 'errorsaving');
                return false;
            }
        } // end if

        if (!empty($replacedata)) {
            // Handle RDN change
            if ($replacedata[$this->prop['LDAP_rdn']]) {
                $newdn = $this->prop['LDAP_rdn'].'='
                    .rcube_ldap_generic::quote_string($replacedata[$this->prop['LDAP_rdn']], true)
                    .','.$this->base_dn;
                if ($dn != $newdn) {
                    $newrdn = $this->prop['LDAP_rdn'].'='
                    .rcube_ldap_generic::quote_string($replacedata[$this->prop['LDAP_rdn']], true);
                    unset($replacedata[$this->prop['LDAP_rdn']]);
                }
            }
            // Replace the fields.
            if (!empty($replacedata)) {
                if (!$this->ldap->mod_replace($dn, $replacedata)) {
                    $this->set_error(self::ERROR_SAVING, 'errorsaving');
                    return false;
                }
            }
        } // end if

        // RDN change, we need to remove all sub-entries
        if (!empty($newrdn)) {
            $subdeldata = array_merge($subdeldata, $subdata);
            $subnewdata = array_merge($subnewdata, $subdata);
        }

        // remove sub-entries
        if (!empty($subdeldata)) {
            foreach ($subdeldata as $fld => $val) {
                $subdn = $fld.'='.rcube_ldap_generic::quote_string($val).','.$dn;
                if (!$this->ldap->delete_entry($subdn)) {
                    return false;
                }
            }
        }

        if (!empty($newdata)) {
            // Add the fields.
            if (!$this->ldap->mod_add($dn, $newdata)) {
                $this->set_error(self::ERROR_SAVING, 'errorsaving');
                return false;
            }
        } // end if

        // Handle RDN change
        if (!empty($newrdn)) {
            if (!$this->ldap->rename($dn, $newrdn, null, true)) {
                $this->set_error(self::ERROR_SAVING, 'errorsaving');
                return false;
            }

            $dn    = self::dn_encode($dn);
            $newdn = self::dn_encode($newdn);

            // change the group membership of the contact
            if ($this->groups) {
                $group_ids = $this->get_record_groups($dn);
                foreach (array_keys($group_ids) as $group_id) {
                    $this->remove_from_group($group_id, $dn);
                    $this->add_to_group($group_id, $newdn);
                }
            }

            $dn = self::dn_decode($newdn);
        }

        // add sub-entries
        if (!empty($subnewdata)) {
            foreach ($subnewdata as $fld => $val) {
                $subdn = $fld.'='.rcube_ldap_generic::quote_string($val).','.$dn;
                $xf = array(
                    $fld => $val,
                    'objectClass' => (array) $this->prop['sub_fields'][$fld],
                );
                $this->ldap->add_entry($subdn, $xf);
            }
        }

        return $newdn ?: true;
    }
1233341
public function inc($table, $data, $condition)
    {
        $collection = $this->db->selectCollection($table);
        $result = $collection->update(
            MongoQueryBuilder::where($condition),
            array('$inc' => self::filterData($data)),
            $this->getOptions());

        return ($result['ok'] == 1 && $result['n'] > 0);
    }
143690
function addCol($col_data, $col_id = 0, $row_id = 0) {
        foreach ($col_data as $col_cell) {
            $this->_data[$row_id++][$col_id] = $col_cell;
        }

        $this->_updateRowsCols();
        $this->_max_cols = max($this->_max_cols, $col_id + 1);
    }
1280101
public function update_config(&$data) {
        if (!empty($data->criteria_unenrol)) {
            $this->course = $data->id;
            $this->insert();
        }
    }
1360472
public function update($table, $data, $cond, $condVars = [])
    {
        $qparts = $qvals = [];
        foreach( $data as $key => $val ) {
            $qparts[] = "`$key` = ?";
            $qvals[] = $val;
        }

        $query = "UPDATE `$table` SET " . implode( ",", $qparts ) . " WHERE " . $cond;
        $qvals = array_merge( $qvals, $condVars );
        return $this->query( $query, $qvals );
    }
886866
public function update_config(&$data) {
        if (!empty($data->criteria_duration)) {
            $this->course = $data->id;
            $this->enrolperiod = $data->criteria_duration_days;
            $this->insert();
        }
    }
1055006
private function processProcessAndCombinationCondition($collection, $cond, $value, $attribute)
    {
        if ($cond == 'null') {
            if ($value == '1') {
                $condition = ['notnull' => true];
            } elseif ($value == '0') {
                $condition = [$cond => true];
            }
        } else {
            if ($cond == 'like' or $cond == 'nlike') {
                $value = '%' . $value . '%';
            }
            //condition with null values can't be filter using sting, inlude to filter null values
            $conditionMap = [$this->conditionMap[$cond] => $value];
            if ($cond == 'eq' || $cond == 'neq') {
                $conditionMap[] = ['null' => true];
            }

            $condition = $conditionMap;
        }

        //filter by quote attribute
        if ($attribute == 'items_qty' && $this->ruleType == self::REVIEW) {
            $collection = $this->filterCollectionByQuoteAttribute($collection, $attribute, $condition);
        } else {
            $collection->addFieldToFilter($attribute, $condition);
        }

        return $collection;
    }