Question

My query is this :

$q = Doctrine_Query::create()           
       ->from('plans p')               
       ->whereIn('c.centerid',$centers)
       ->andWhere('p.agecategory = ?', $ageType)      
       ->andWhere('p.type = ?', '2')       
       ->andWhere('p.active = ?', '1')    
       ->leftJoin('p.plansCenters c');  
       return $q->execute();

I wont to add one more row :

orWhere('p.allcenters =?' , '1')

Problem is this : I wont to remove this whereIn clouse if c.allcenters =? 1 and oposit if c.allcenters =? 0 to show query whit whereIn clouse. If i wrhite orWhere after WhereIn clouse this 3 andWhere after this dont work Please help :)

Was it helpful?

Solution

I didn't fully understand the problem but I am familiar with complex orWhere/andWhere clauses. You have to use combined where conditions likes this:

->where("q.column=? AND w.column=?", ...)
->orWhere("e.id=? AND r.name=?", ....)
->orWhere("t.id=? AND (y.id=? OR u.id=?)", ...)

I hope you understand the idea, this is perfectly legit way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top