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]);
} }