
Untitled
By: a guest on
Apr 28th, 2012 | syntax:
None | size: 0.63 KB | hits: 17 | expires: Never
Doctrine Fixtures: getOrder() with Join Tables
$book1->addBookAuthor($manager->merge($this->getReference('book-author-1')));
$bookAuthor1->setBook($manager->merge($this->getReference('book-1')));
/**
* @ORMOneToMany(targetEntity="yourbundleEntityBookAuthor",mappedBy="book", cascade={"persist", "remove"})
*/
protected $book_authors;
// [...]
$book = new Book();
$book->setTitle( 'xxx' )
// Set more data...
$book_author = new BookAuthor();
$book_author->setAuthor( $manager->merge($this->getReference('author-1')) );
$book_author->setBook( $book );
$book->addBookAuthor( $book_author );
$em->persist( $book );
// [...]