Last active
August 29, 2015 14:16
-
-
Save nicosomb/baf9e975ab60d12f7404 to your computer and use it in GitHub Desktop.
relation entry <-> tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// mon test | |
$entry = $client->getContainer() | |
->get('doctrine.orm.entity_manager') | |
->getRepository('WallabagCoreBundle:Entry') | |
->findOneWithTags(); | |
$entry->getTags(); // --> Call to a member function getTags() on a non-object | |
// mon repository | |
public function findOneWithTags() | |
{ | |
$qb = $this->createQueryBuilder('e') | |
->innerJoin('e.tags', 't') | |
->addSelect('t') | |
->setMaxResults(1); | |
return $qb | |
->getQuery() | |
->getResult(); | |
} | |
// mon entité Entry | |
// ... | |
/** | |
* @return ArrayCollection<Tag> | |
*/ | |
public function getTags() | |
{ | |
return $this->tags; | |
} |
innetJoin ? connais pas ;-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Juste ça, ça suffit pas ?