I would like to create a search form. My price ranges are:
public static function getPrice_list(){
$model = array(
0=>"0 - 250.000",
1=>"250.000 - 600.000",
2=>"600.000 - 1.000.000",
3=>"1.000.000 -",
4=>"Every",
);
return $model;
}
The advert model relation is:
'price'=>array(self::HAS_MANY, 'UserAndApartmanPrice', 'user_and_apartman_id')
Every advert has 4 price:
1., defalult valuta for sell.
2., choosen valuta for sell.
3.,default valuta for rent.
4., chosen valuta for rent.
3 and 4 have same value
in database. main = 10
So i need something like:
$criteria = new CDbCriteria;
$criteria->with = array( 'apartman','price');
$criteria->together = true;
if($_POST['sell_price'] != 4){
if($_POST['sell_price'] == 0){
// this is the question
}
...
}
$model = UserAndApartman::model()->findAll($criteria);
So i would like to search in a HAS_MANY
realation, where main != 10 AND valuta = 1 AND value between 2 price
.