Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何在模型的事件,例如onAfterUpdate()获取到更新的data以及条件where ? #567

Open
yuyanpeng123 opened this issue Feb 14, 2023 · 0 comments

Comments

@yuyanpeng123
Copy link

yuyanpeng123 commented Feb 14, 2023

EasySwoole版本:3.3.7
ORM版本:1.4.30
Dao
<?php class V3OrderDao extends AbstractModel { protected $tableName = 'v3_order'; }

Service
$primaryKey = 202302141026000001;

// 场景1,可能有很多更新字段
$model1 = V3OrderDao::create()->where('order_id', $primaryKey)->get(); $model1->update(['updated_at' => time()]);

// 场景2,可能有很多更新字段
$model2 = V3OrderDao::create()->get($primaryKey); $model2->updated_at = time(); $model2->update();

// 场景3,可能有很多更新字段
V3OrderDao::create()->update(['updated_at' => time()], ['order_id' => $primaryKey]);

// 场景4,可能有很多更新字段
V3OrderDao::create()->where('order_id', $primaryKey)->update();

实际的业务逻辑复杂,很难通过业务代码层面存更新的data和where。如何在模型的事件,例如onAfterUpdate()获取到更新的data以及条件where ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant