I'm a developper beginner (and my first question here) and unsure of a DQL query expression vs equivalent SQL expression I want to run in database.
SQL query is :
SELECT *
FROM table
*[other WHERE CONDITIONS]*
WHERE (field-A = 2 AND field-B IS NULL) OR (field-A = 2 AND field-B IS NULL);
On the Symfony side, I'm not sure what I'm doing in terms of nesting AND / OR operators. I think that :
$qb = $this->createQueryBuilder('t');
*[other WHERE CONDITIONS]*
$qb->andWhere(function ($qb, $data) {
$qb->where(isNull('t.field-A'))
->andWhere('t.field-B = :data')
->orWhere('t.field-A = :data')
->andWhere(isNull('t.field-B'))
->setParameter('data', $data);
});
Do you think my DQL query is correct compared to the SQL query ?
Thank you all for your help