WHERE a = 1 AND (b = 1 Or b = 2) AND (c = 1 OR c = 2)
How can i make this in Doctrine?
$q->where(\"a = 1\");
$q->andWhere(\"b
One thing missing here: if you have a varying number of elements that you want to put together to something like
WHERE [...] AND (field LIKE '%abc%' OR field LIKE '%def%')
and dont want to assemble a DQL-String yourself, you can use the orX mentioned above like this:
$patterns = ['abc', 'def'];
$orStatements = $qb->expr()->orX();
foreach ($patterns as $pattern) {
$orStatements->add(
$qb->expr()->like('field', $qb->expr()->literal('%' . $pattern . '%'))
);
}
$qb->andWhere($orStatements);