src/Leevel/Database/Ddd/Entity.php
protected function updateReal(?array $fill = null): IEntity
    {
        $this->leevelFlushed = false;

        $this->parseAutoFill('update', $fill);

        $propKey = $this->normalizeWhiteAndBlack(
            array_flip($this->leevelChangedProp), 'update_prop'
        );

        $saveData = [];

        foreach ($this->leevelChangedProp as $prop) {
            if (!array_key_exists($prop, $propKey)) {
                continue;
            }

            $saveData[$prop] = $this->__get($prop);
        }

        if (!$saveData) {
            return $this;
        }

        $condition = [];

        foreach ($this->primaryKeys() as $field) {
            if (isset($saveData[$field])) {
                unset($saveData[$field]);
            }

            if ($value = $this->__get($field)) {
                $condition[$field] = $value;
            }
        }

        if (empty($condition) || empty($saveData)) {
            return $this;
        }

        $this->leevelFlush = function ($condition, $saveData) {
            $this->handleEvent(static::BEFORE_UPDATE_EVENT, $saveData, $condition);

            $num = $this->metaConnect()->update($condition, $saveData);

            $this->handleEvent(static::BEFORE_UPDATE_EVENT, null, null);

            $this->clearChanged();

            $this->handleEvent(static::AFTER_UPDATE_EVENT);

            return $num;
        };

        $this->leevelFlushData = [$condition, $saveData];

        return $this;
    }
protected function updateReal(?array $fill = null): IEntity
    {
        $this->leevelFlushed = false;

        $this->parseAutoFill('update', $fill);

        $propKey = $this->normalizeWhiteAndBlack(
            array_flip($this->leevelChangedProp), 'update_prop'
        );

        $saveData = [];

        foreach ($this->leevelChangedProp as $prop) {
            if (!array_key_exists($prop, $propKey)) {
                continue;
            }

            $saveData[$prop] = $this->__get($prop);
        }

        if (!$saveData) {
            return $this;
        }

        $condition = [];

        foreach ($this->primaryKeys() as $field) {
            if (isset($saveData[$field])) {
                unset($saveData[$field]);
            }

            if ($value = $this->__get($field)) {
                $condition[$field] = $value;
            }
        }

        if (empty($condition) || empty($saveData)) {
            return $this;
        }

        $this->leevelFlush = function ($condition, $saveData) {
            $this->handleEvent(static::BEFORE_UPDATE_EVENT, $saveData, $condition);

            $num = $this->metaConnect()->update($condition, $saveData);

            $this->handleEvent(static::BEFORE_UPDATE_EVENT, null, null);

            $this->clearChanged();

            $this->handleEvent(static::AFTER_UPDATE_EVENT);

            return $num;
        };

        $this->leevelFlushData = [$condition, $saveData];

        return $this;
    }
更新数据.

@param null|array $fill

@return $this