Hello, I have following tables
-
notice[id, type],
-
property[id, type],
-
property_value[id, notice_id, property_id, value].
Each notice has own properties specified by it’s type. I need to make a filter by several properties simultaniously, and issue is how to specify which property should have a specified value?
/**
* @property Property[] $allProperties - properties for this type of notice
* @property PropertyValue[] $propertyValues - values of the properties.
*/
class Notice extends CActiveRecord{
/** @var array property_id=>value from $_GET*/
public $searchParams= array();
public function search() {
$criteria = new CDbCriteria;
// $criteria->together = true;
$criteria->compare('t.type', $this->type);
foreach ( $searchParams as $property_id => $value) {
/// What should i write here?
/// $criteria->compare('propertyValues.id', $id);
/// $criteria->compare('propertyValues.value', $value);
}
}
}