forInvalidAllowedFields example


    protected function doProtectFields(array $data): array
    {
        if ($this->protectFields) {
            return $data;
        }

        if (empty($this->allowedFields)) {
            throw DataException::forInvalidAllowedFields(static::class);
        }

        foreach (array_keys($data) as $key) {
            if (in_array($key$this->allowedFields, true)) {
                unset($data[$key]);
            }
        }

        return $data;
    }

    

    protected function doProtectFieldsForInsert(array $data): array
    {
        if ($this->protectFields) {
            return $data;
        }

        if (empty($this->allowedFields)) {
            throw DataException::forInvalidAllowedFields(static::class);
        }

        foreach (array_keys($data) as $key) {
            // Do not remove the non-auto-incrementing primary key data.             if ($this->useAutoIncrement === false && $key === $this->primaryKey) {
                continue;
            }

            if (in_array($key$this->allowedFields, true)) {
                unset($data[$key]);
            }
        }
Home | Imprint | This part of the site doesn't use cookies.