开发者

Doctrine Uni-Directional ManyToOne and Cascades

开发者 https://www.devze.com 2023-02-07 00:28 出处:网络
I have the following setup Todos have Notes Notes are authored by Users . class Todo { protected $notes; } class Note {

I have the following setup

  • Todos have Notes
  • Notes are authored by Users

.

class Todo {
    protected $notes;
}

class Note {
    protected $todo;
    protected $author;
}

class User {
    // does not have any link to Note. 
}

User does not have any link to Note, how do I then cascade my persist there. I thought Note being the owning side of the relationship, I just need $note->author = $user. And won't need something li开发者_如何转开发ke $user->getNotes()->add($author). I was thinking if in my app, if I don't need to access Notes from Users, I don't add a link to clutter my class.


I'm not sure if I get this right, but; if your User doesn't have a reference to their notes then you won't need to cascade any actions because it's a uni-directional relationship.

Be sure to re-read Working with Associations.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号