Reputation: 113
In Doctrine2, I have this code:
$em = $this->getDoctrine()->getEntityManager();
$qb = $em->createQueryBuilder();
$qb->from('TestBundle:Message', 'm')
->join('m.product', 'p')
->where('m.delDate IS NULL');
//create the OR request
$orModule = $qb->expr()->orx();
$orModule->add($qb->expr()->eq('p.module', ':module'));
$orModule->add($qb->expr()->isNull('p.module'));
$qb->andWhere($orModule)->execute();
I want this code in Doctrine 1.2.
Upvotes: 0
Views: 46
Reputation: 218
I'm not sure, but I think what you want to do may be something like (by memory and, yes, it's ugly) :
$q = new Doctrine_Query();
$q->from('MyTable t')
->where('t.name = ?', $name)
->andWhere('(TRUE')
->andWhere('t.firstname = ?', $var1)
->orWhere('t.firstname = ?', $var2)
->andWhere('TRUE)')
;
Good luck with this old friend!
Upvotes: 0