CAKEPHP 4-与协会一起保存
我在保存与关联的数据方面有问题。问题在于,我在后卫上做事,关联正在触发主要实体($ tosave)。这是正常的吗? 就像首先保存关联,然后是主要实体。是否改变了储蓄顺序?有意义吗?
$toSave = $this->{MODEL_NAME}->patchEntity($toSave, $postData, ['associated' => ['SomeAssociation']]);
if ($this->{MODEL_NAME}->save($toSave)) {
}
版本:Cakephp 4.x
谢谢。
I am having problems with saving data with associated. The problem is that i'm do thing on AfterSave and the associations are triggering the AfterSave before the principal entity($toSave). This is normal?
It's like first save the associations then the principal entity. Is a way of changing the order of saving? Makes sense?
$toSave = $this->{MODEL_NAME}->patchEntity($toSave, $postData, ['associated' => ['SomeAssociation']]);
if ($this->{MODEL_NAME}->save($toSave)) {
}
Version: Cakephp 4.x
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论