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.
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!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.