// Restore $cleanValidationRules
$this->cleanValidationRules =
$cleanValidationRules;
// Must be called first, so we don't
// strip out created_at values.
$data =
$this->
doProtectFieldsForInsert($data);
// doProtectFields() can further remove elements from
// $data so we need to check for empty dataset again
if (!
$this->allowEmptyInserts &&
empty($data)) { throw DataException::
forEmptyDataset('insert'
);
} // Set created_at and updated_at with same time
$date =
$this->
setDate();
if ($this->useTimestamps &&
$this->createdField && !
array_key_exists($this->createdField,
$data)) { $data[$this->createdField
] =
$date;
} if ($this->useTimestamps &&
$this->updatedField && !
array_key_exists($this->updatedField,
$data)) { $data[$this->updatedField
] =
$date;
}