search help

ok here i have a model like




class1{

var text1=one;

var text2=two;

var text3=three;

}

class2{

var text1=two;

var text2=one;

var text3=three;

}

class3{

var text1=one;

var text2=three;

var text3=three;

}



so lets say i would like to search for all models with attributes that are one two and three

and only return class1 and class2 but not class3

how would i accomplish this??

model names are really the same just changed for clarity, query is from from the same db table. instantiating this should be an array of objects with each object being




array([0]->object->class1,[1]->object->class2,[2]->object->class3);



You essentially need to do:


SELECT * FROM `tablename` WHERE 'one' IN (t1,t2,t3) AND 'three' IN (t1,t2,t3) AND 'two' IN (t1,t2,t3)

You could:




$criteria = new CDbCriteria;

$criteria->condition = ':p1 IN (text1,text2,text3) AND :p2 IN (text1,text2,text3) AND :p3 IN (text1,text2,text3)';

$criteria->params = array(':p1'=>'one', ':p2'=>'two', ':p3'=>'three');


Class1::model()->findAll( $criteria );