开发者

Doctrine Uni-Directional ManyToOne and Cascades

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜