mysql - how to query record with multiple condition using yii framework -
i want results satisfy (age=20, name=jim) or (age=30, name=allen) or (age=40, name=sam), how write query code yii?
if use yii 1:
$criteria = new cdbcriteria(); $criteria->addcondition('age = :age1 , name = :name1', 'or'); $criteria->addcondition('age = :age2 , name = :name2', 'or'); $criteria->addcondition('age = :age3 , name = :name3', 'or'); $criteria->params = [ ':age1' => 20, ':age2' => 30, ':age3' => 40, ':name1' => 'jim', ':name2' => 'allen', ':name3' => 'sam', ]; $result = yourmodelname::model()->findall($criteria);
Comments
Post a Comment