set update data
@param  string|array $data
@param  string|array $where
@return static
172534
public function set($data=null, $where=null)
    {
        if ($data)  {
            $this->getQuery()->set('data', $data);
        }
        if ($where) {
            $this->where($where);
        }
        
        return $this;
    }
796476
public function update($tableName, array $data, $where = null)
    {
        list($where, $params) = $this->_buildWhere($where);
        
        $set = array();
        foreach ($data as $column => $value) {
            $set[] = "$column = ?";
        }
        $query = "UPDATE $tableName SET " . implode(', ', $set) . " $where";
        $params = array_merge(array_values($data), $params);
        
        $stmt = $this->prepare($query);
        $stmt->execute($params);
        return $stmt;
    }
904364
private function preparedUpdate($data,$where){
        $sqldata = empty($data)?$this->_ar:$data;
        $sql = $this->dealUpdateSQL($this->GetTable(),$sqldata,$where);
        $phl = $this->dbh->prepare($sql);
        $res = $phl->execute($sqldata);
        $this->initialize();
        return $res;
    }
623476
public function setRawData(array $data)
    {
        $this->data = $data + $this->data;

        if ($data) {
            $this->loaded = true;
            $this->setDataSource('*', 'db');
        }

        return $this;
    }
675048
public function updateIf($data)
    {
        $updated = false;
        foreach ($data as $key => $val) {
            if ($val) {
                $this->{$key} = $val;
                $updated = true;
            }
        }

        if ($updated) {
            $this->save();
        }

        return $this;
    }
520893
public function setData(array $data)
    {
        foreach ($this->getData()->toArray() as $key => $value) {
            $this->getData()->offsetUnset($key);
        }

        $this->addData($data);

        return $this;
    }
715713
public function insert_or_update( $table, $data, $where ) {
		if ( ! isset( $this->table_defines[ $table ] ) ) {
			return false;
		}

		if ( $this->is_logical( $this->table_defines[ $table ] ) ) {
			$where['deleted_at'] = null;
		}

		$row = $this->select_row( $table, $where, 'id' );
		if ( empty( $row ) ) {
			$this->insert( $table, $data );
			if ( $this->get_last_error() ) {
				return false;
			}

			return $this->get_insert_id();
		}
		$where = [ 'id' => $row['id'] ];
		$this->update( $table, $data, $where );
		if ( $this->get_last_error() ) {
			return false;
		}

		return $row['id'];
	}
1006801
public function update($table, $data, $where = '')
    {
        $fieldDetails = null;
        foreach ($data as $key => $value) {
            $fieldDetails .= "$key = :$key,";
        }
        $fieldDetails = rtrim($fieldDetails, ',');
        $query = "UPDATE $table SET $fieldDetails ".($where ? 'WHERE '.$where : '');
        $this->prepare($query);

        foreach ($data as $key => $value) {
            $this->bind(":$key", $value);
        }
        try {
            $this->execute();

            return true;
        } catch (PDOException $e) {
            echo $e->errorInfo[2];

            return false;
        }
    }
45800
public function update($data, $where = [])
    {
        /*
         | Trigger Before Update events if
         | defined by user into model class
         |
         */
        $this->triggerEvent('beforeUpdate');

        if (!empty($where)) {
            $whereStr = $this->buildWherePlaceholderName($where);
        } else {
            list($where, $whereStr) = $this->buildWhereForUpdate();
        }

        $sql = $this->getUpdateQuery($data, strtoupper(__FUNCTION__)).$whereStr;

        try {
            $stmt = $this->resolveConnection()->prepare($sql);

            //Bind all values to query statement
            foreach ($data as $key => $val) {
                $stmt->bindValue(":$key", $val);
            }

            foreach ($where as $key => $value) {
                $stmt->bindValue(":$key", $value);
            }

            static::$queries[] = $stmt->queryString;
            $affectedRow = $stmt->execute();

            /*
             | Trigger after update events if defined
             | into model class
             |
             */
            $this->triggerEvent('afterUpdate');

            return $affectedRow;
        } catch (\PDOException  $exception) {
            throw new \Exception($exception->getMessage());
        }
    }
521412
public static function update(array $data, array $where): int
    {
        $self = static::getInstance();

        $data = static::filterColumns($data);

        if (!\count($data)) {
            throw new DbException(
                "Invalid field names of table `{$self->name}`. Please check use of `update()` method"
            );
        }

        $where = static::filterColumns($where);

        if (!\count($where)) {
            throw new DbException(
                "Method `Table::update()` can't update all records in the table `{$self->name}`,\n" .
                "please use `Db::query()` instead (of cause if you know what are you doing)"
            );
        }

        $table = DbProxy::quoteIdentifier($self->name);

        $sql = "UPDATE $table SET " . implode(',', self::prepareStatement($data))
            . " WHERE " . implode(' AND ', self::prepareStatement($where));

        return DbProxy::query($sql, array_merge(array_values($data), array_values($where)));
    }
785077
public static function update($table, $data = null, $where = null) {
        if ($data) {
            Update::update($table, $data, $where);
            return null;
        } else {
            return Update::table($table);
        }
    }
102848
public function setData(array $data)
    {
        if (isset($data['name'])) {
            $this->setName($data['name']);
        }

        if (isset($data['active'])) {
            $this->setActive($data['active']);
        }

        return $this;
    }
622876
public function insertOrUpdate($table, array $set, array $where)
    {
        if ($this->select($table, $where)) {
            $result = $this->update($table, $set, $where);
        } else {
            $params = array_merge($where, $set);
            $result = $this->insert($table, $params);
        }

        return $result;
    }
961247
public function save($data=null, $where=null)
    {
        $this->set($data, $where);
        $query = $this->getQuery();
        
        if (isset($query['table'])) {
            $table = $query['table'][0];
            $pk = $this->getPrimaryKey($table);
        } else {
            $table = $this->getTableName();
            $pk = $this->getPrimaryKey();
        }
        if (!isset($pk)) {
            throw new Exception('Can\'t get primary key of table:' . $table);
        }
        if ($data && isset($data[$pk]) && $data[$pk]) {
            $this->where([$pk => $data[$pk]]);
        }
        
        // verify data
        $mdata = $query->get('data');
        $mwhere = $query->get('where');
        
        if (!$query->formatted()) {
            $mdata = static::formatInput($mdata);
            $query->remove('data')->setRaw('data', $mdata);
            
            $res = static::verifyData($mdata);
            if ($res['errcode']) {
                return $res;
            }
        }
        
        if (static::isEmptyData($mdata)) {
            return ErrorInfo::error('没有更新的数据');
        }
        
        if (!$mwhere) {
            // clone query
            $clone = $query->clone();
            $res = static::setQuery($clone)->verifyUnique($mdata, $mwhere);
            if ($res['errcode']) {
                return $res;
            }
        }
        
        $row = null;
        if (!empty($mwhere)) {
            // clone query
            $this->setQuery($query->clone());
            $row = $this->find();
        }
        
        if ($row) {
            $this->setQuery($query)->update()->query();
            
            $id = $row[$pk];    // first row id
        } else {
            $id = $this->setQuery($query)->insert()->query(); // insert id
            
            if (!$id) {
                return ErrorInfo::error('操作未获取 insertId');
            }
        }
        
        return ErrorInfo::success(['id' => $id]);
    }
719676
public function update($table, array $data, $where = [], array $bind = [])
    {
        $table  = $this->quote()->identifier($table);
        $fields = [];
        foreach ($data as $field => $value) {
            $fields[] = $this->quote()->into("{$field} = ?", $value);
        }
        $sql = "UPDATE $table SET " . implode(', ', $fields);
        if (is_array($where)) {
            $where = $this->createWhereExpression($where);
        }
        $sql .= (($where) ? " WHERE {$where}" : '');

        $stmt = $this->query($sql, $bind);

        return $stmt->rowCount();
    }
630841
public function update($data = [], $wheres = [])
    {
        if (is_array($wheres) && count($wheres) > 0) {
            foreach ($wheres as $column => $column_value) {
                if (is_array($column_value)) {
                    $this->db->where($column, $column_value, self::OPERATOR_IS_IN);
                } else {
                    $this->db->where($column, $column_value, self::OPERATOR_EQUAL_TO);
                }
            }
        }
        if ($this->db->update($this->table, $data)) {
            return (int) $this->db->count;
        }

        return 0;
    }
1110102
public function set(array $data)
    {
        foreach ($data as $field => $value) {
            $this->fields[] = $field;
            $this->dataParameters[":{$field}"] = $value;
        }
        return $this;
    }