Hi, I am new at Yii. I had a legacy project on Yii version 1.1.10 which was running fine when it was on server in 2013. Now I need to make a project on it. Website gives me errors at some pages. Have been searching solution for days. Any solutions? Thanks.
Use of undefined constant status assumed 'status'
is "status" field available in your model ?
Here is model for flats. I have MySQL databse it it with all data. When i delet old data and enter new flat same bug appiers. Maby this is with wrong setup? Becouse i was told that the code is fine and has been working porperly.
<?php
/**
* This is the model class for table "flats".
*
* The followings are the available columns in table 'flats':
* @property integer $id
* @property integer $variant
* @property string $flat_nr
* @property integer $floor
* @property integer $rooms
* @property string $windows_direction
* @property double $flat_area
* @property double $balcony_terrace_area
* @property double $parking_price
* @property double $price
* @property double $total_price
* @property integer $status
*/
class Flats extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Flats the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'flats';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('terrace_area, yard_area', 'terraceYardValidator'),
array('variant, flat_nr, floor, rooms, windows_direction, flat_area, balcony_terrace_area, parking_price, price, total_price', 'required'),
array('variant, floor, rooms, status', 'numerical', 'integerOnly'=>true),
array('flat_area, balcony_terrace_area, parking_price, price, total_price, old_price', 'numerical'),
array('flat_nr, windows_direction', 'length', 'max'=>50),
array('smallest_flat, old_price','defaultValidaror'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, variant, flat_nr, floor, rooms, windows_direction, flat_area, balcony_terrace_area, parking_price, price, total_price, status', 'safe', 'on'=>'search'),
);
}
public function defaultValidaror(){}
public function terraceYardValidator(){
$this->yard_area = str_replace (",", ".", $this->yard_area);
$this->terrace_area = str_replace (",", ".", $this->terrace_area);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'variant' => 'Aukšto variantas',
'flat_nr' => 'Buto numeris',
'floor' => 'Aukštas',
'rooms' => 'Kambarių skaičius',
'windows_direction' => 'Langų kryptis',
'flat_area' => 'Buto plotas',
'balcony_terrace_area' => 'Balkono plotas (0, jei nėra)',
'terrace_area' => 'Terasos plotas (0, jei nėra)',
'yard_area' => 'Kiemelio plotas (0, jei nėra)',
'parking_price' => 'Parkingo kaina',
'smallest_flat' => 'ID kitų butų esančių šio buto ribose',
'old_price' => 'Akcijinė buto kaina arba 0, jei akcijos nėra',
'price' => 'Buto kaina',
'total_price' => 'Parkingo + buto kaina',
'status' => 'Buto statusas',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('variant',$this->variant);
$criteria->compare('flat_nr',$this->flat_nr,true);
$criteria->compare('floor',$this->floor);
$criteria->compare('rooms',$this->rooms);
$criteria->compare('windows_direction',$this->windows_direction,true);
$criteria->compare('flat_area',$this->flat_area);
$criteria->compare('balcony_terrace_area',$this->balcony_terrace_area);
$criteria->compare('parking_price',$this->parking_price);
$criteria->compare('price',$this->price);
$criteria->compare('total_price',$this->total_price);
$criteria->compare('status',$this->status);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'pagination' => array (
'PageSize' => 50 //edit your number items per page here
),
'sort'=>array(
'defaultOrder'=>'id ASC',
),
));
}
}