0

How to create cdbcriteria fo the query like :

select * from table_name where 'profile_type'='*'OR 'profile_type'=$usertype  AND 'location'='*'OR 'location'=$country
Kumar V
  • 8,810
  • 9
  • 39
  • 58

2 Answers2

1

You can directly pass condition as below.

Note: This is one of the method. Not an ultimate solution.

$criteria = new CDbCriteria;
$criteria->condition  = "(profile_type ='*' OR profile_type = $usertype)  AND (location ='*' OR location = $country)";

$model = Model_name::model()->findAll($criteria );
Kumar V
  • 8,810
  • 9
  • 39
  • 58
1

you can try sth like this:

$criteria = new CDbCriteria;
$criteria->condition  = "(profile_type='*' OR profile_type=:prof ) AND 
                         (location='*' OR  location=:loc ) ";

$criteria->params = array(':prof' => $usertype, ':loc' => $country);

$model = MyModel::model()->findAll($criteria );
sakhunzai
  • 13,900
  • 23
  • 98
  • 159