Exemplo n.º 1
0
 public function actionAutocomplete()
 {
     $this->layout = false;
     $criteria = new CDbCriteria();
     $criteria->addSearchCondition('t.property_name_or_address', ActiveRecord::safeField($_GET['term']), true);
     $criteria->compare('t.status', STATUS_ACTIVE);
     $criteria->compare('t.user_id', $this->userID);
     //        $criteria->limit = 20;
     $models = Listing::model()->findAll($criteria);
     $returnVal = array();
     foreach ($models as $model) {
         $returnVal[] = array('label' => $model->property_name_or_address, 'value' => $model->property_name_or_address, 'Listing_property_type_1' => $model->property_type_1, 'Listing_property_type_2' => $model->property_type_2, 'Listing_unit_from' => $model->unit_from, 'Listing_unit_to' => $model->unit_to, 'Listing_price' => Listing::getformatPrice($model->price), 'Listing_office_bkank_valuation' => Listing::getformatPrice($model->office_bkank_valuation), 'Listing_of_bedroom' => $model->of_bedroom, 'Listing_floor_area' => $model->floor_area, 'Listing_hdb_town_estate' => $model->floor_area, 'Listing_developer' => $model->developer, 'Listing_tenure' => $model->tenure, 'Listing_field' => $model->postal_code, 'Listing_postal_code' => $model->postal_code, 'Listing_postal_code_xy' => $model->postal_code_xy);
     }
     echo CJSON::encode($returnVal);
     Yii::app()->end();
 }