Reputation: 126
How to create cdbcriteria fo the query like :
select * from table_name where 'profile_type'='*'OR 'profile_type'=$usertype AND 'location'='*'OR 'location'=$country
Upvotes: 0
Views: 87
Reputation: 8838
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 );
Upvotes: 1
Reputation: 14470
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 );
Upvotes: 1