1. In Yii2, for an update interface, if the record in the table has already been deleted before executing save(), it will still return true. Does this situation need to be avoided? See Figure 1.

2. The code implementation is as follows.
PHP
$animation = InvitationPageElementAnimation::find()->where([
'id' => $id,
])->with(['invitation'])->limit(1)->one();
$executeRes = Yii::$app->db->createCommand('DELETE FROM `invitation_page_element_animations` WHERE id=:id')
->bindValue(':id', $id)
->execute();
Yii::info(
[
$executeRes
],
'$executeRes'
);
try {
$res = $animation->save(false);
Yii::info(
[
$res
],
'$res'
);
if (!$res) {
return [
'code' => 10400,
'message' => '设置动画属性失败',
];
}
return [
'code' => 10000,
'message' => '设置动画属性成功',
'data' => $animation,
];
} catch (Throwable $e) {
Yii::error([
'exception' => get_class($e),
'message' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTraceAsString(),
], 'application.model.save.exception');
return [
'code' => 10500,
'message' => '数据库操作失败,请联系管理员',
];
}
3. Decided not to adjust it for now.
