Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 0.63 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Doctrine Fixtures: getOrder() with Join Tables
  2. $book1->addBookAuthor($manager->merge($this->getReference('book-author-1')));
  3.        
  4. $bookAuthor1->setBook($manager->merge($this->getReference('book-1')));
  5.        
  6. /**
  7.  * @ORMOneToMany(targetEntity="yourbundleEntityBookAuthor",mappedBy="book", cascade={"persist", "remove"})
  8.  */
  9. protected $book_authors;
  10.        
  11. // [...]
  12. $book = new Book();
  13. $book->setTitle( 'xxx' )
  14. // Set more data...
  15. $book_author = new BookAuthor();
  16. $book_author->setAuthor( $manager->merge($this->getReference('author-1')) );
  17. $book_author->setBook( $book );
  18. $book->addBookAuthor( $book_author );
  19.  
  20. $em->persist( $book );
  21.  
  22. // [...]