2012-11-19 38 views
0

我的查詢是這樣的:主義查詢,其中,與orWhere

$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(); 

我不會再添加一個行:

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

問題是這樣的: 我不會當c刪除此其中克勞斯。 allcenters =? 1和oposit如果c.allcenters =? 0顯示查詢白衣在哪裏clouse。如果我wrhite或之後在哪裏clouse這3和在此之後不工作請幫助:)

回答

0

我沒有完全理解這個問題,但我熟悉複雜或Where/Where從句。你必須結合使用條件如下:

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

我希望你明白這個想法,這是完全合法的方式。