php - Doctrine associations owning vs inverse side -


in doctrine association reference manual it's mentioned

of course, in correct application semantics of bidirectional association maintained application developer (that’s responsibility)

i haven't been able find concrete example on how developer should maintain association. appreciated.

there example in symfony documentation this: http://symfony.com/doc/master/cookbook/form/form_collections.html

around middle of page is stated that:

a second potential issue deals owning side , inverse side of doctrine relationships. in example, if "owning" side of relationship "task", persistence work fine tags added task. however, if owning side on "tag", you'll need little bit more work ensure correct side of relationship modified.

in particular example, doctrine documentation mentioned relate part of entities code:

// src/acme/taskbundle/entity/task.php  // ... public function addtag(arraycollection $tag) {     $tag->addtask($this);      $this->tags->add($tag); } 

and

// src/acme/taskbundle/entity/tag.php  // ... public function addtask(task $task) {     if (!$this->tasks->contains($task)) {         $this->tasks->add($task);     } } 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -