How To Create Traditional Query Using Critieria With Conditions


select * from `table_name` where `col1`='val' and (`col2` between 1 and 50 OR `col2` between 70 and 100  OR `col3` between 1 and 50 OR `col3` between 70 and 100)

In img1.0 category is col1 and price area is col2 and col3 resply.

Category AND (PRICE1 OR PRICE2 OR AREA1 OR AREA2) like this. how to achieve this using CDbCriteria.

How to build query

4775

refine1.png

4776

refine2.png

I think you can try this




$criteria = new CDbCriteria;

$criteria->select = 't.*';

$criteria->addCondition("col1 = 'val' AND 'col2' BETWEEN 1 AND 50 OR 'col2' BETWEEN 70 AND 100 OR 'col3' BETWEEN 1 AND 50 'col3' between 70 and 100)");

$resultSet    =    table_name::model()->findAll($criteria);


return $resultSet;