Last active
January 2, 2016 16:59
-
-
Save pumatertion/8333990 to your computer and use it in GitHub Desktop.
Accessing QueryBuilder and add additional where statement f.e.
This file contains 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
class FooRepository extends Repository { | |
/** | |
* @return QueryResultInterface | |
*/ | |
public function findAllWhereSenderEqualsRecipient() { | |
$query = $this->createQuery(); | |
/** | |
* @var \Doctrine\ORM\QueryBuilder $queryBuilder | |
*/ | |
$queryBuilder = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($query, 'queryBuilder', TRUE); | |
/** | |
* @var \Doctrine\ORM\Query\Expr\From $from | |
*/ | |
$from = $queryBuilder->getDQLPart('from')[0]; | |
// Only those where sender equals recipient | |
$queryBuilder->andWhere($from->getAlias() . '.sender = ' . $from->getAlias() . '.recipient'); | |
return $query->execute(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment