Skip to content

Instantly share code, notes, and snippets.

@pumatertion
Last active January 2, 2016 16:59
Show Gist options
  • Save pumatertion/8333990 to your computer and use it in GitHub Desktop.
Save pumatertion/8333990 to your computer and use it in GitHub Desktop.
Accessing QueryBuilder and add additional where statement f.e.
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