Hi all,
I am new in Yii.
And I found a problem, CDbCriteria skips the first conditions only works the order.
It is very probably that I'm just not using "condition" correctly.
Could someone tell me what I have wrong?
Thank you very much in advance.
I am new in Yii.
And I found a problem, CDbCriteria skips the first conditions only works the order.
It is very probably that I'm just not using "condition" correctly.
Could someone tell me what I have wrong?
Thank you very much in advance.
public function actionIndex($c=null,$p=null,$o=null) { $criteria=new CDbCriteria(); if (isset($c)){ $criteria->condition='categoria=:categoria'; $criteria->params=array(':categoria'=>$c); } if (isset($p)){ $criteria->condition='provincia=:provincia'; $criteria->params=array(':provincia'=>$p); } $criteria->condition='activa=:activa'; $criteria->params=array(':activa'=>1); if (isset($o) and $o==1){ $criteria->order = "preciodesde ASC"; } if (isset($o) and $o==2){ $criteria->order = "preciodesde DESC"; } if (isset($o) and $o==3){ $criteria->order = "vip ASC"; $criteria->order = "vip_precio DESC"; $criteria->condition='vip=:vip'; $criteria->params=array(':vip'=>1); } $count=Empresa::model()->count($criteria); $pages=new CPagination($count); // results per page $pages->pageSize=10; $pages->applyLimit($criteria);