Skip to content

Instantly share code, notes, and snippets.

@mberhorst
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mberhorst/73e5f451c461818e91c6 to your computer and use it in GitHub Desktop.
Save mberhorst/73e5f451c461818e91c6 to your computer and use it in GitHub Desktop.
Example for direct access of doctrine queryBuilder in TYPO3 Flow
$q = $this->createQuery();
// hack -> we directly access the queryBuilder from the current query $q
$qb = ObjectAccess::getProperty($q, 'queryBuilder', TRUE);
$qb
->andWhere('e.shortName = :term')
->setParameter('term', $term);
if ($productType) {
$qb
->leftJoin('e.type', 't')
->andWhere('t.value = :productType')
->setParameter('productType', $productType);
}
if ($hasIssue) {
$qb
->join('e.issues', 'i')
->groupBy('e')
->having('COUNT(i) > 0');
}
return $q->execute();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment