i have a model A without field ‘thumb’, after then i added a new field ‘thumb’ in the datebase, and modified the model as below:
public function tableName()
{
return '{{Photos}}';
}
/**
* @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('status, user_id', 'required'),
array('status, photocate_id, events_id, user_id', 'numerical', 'integerOnly'=>true),
array('image,thumb, note', 'length', 'max'=>128),
);
}
/**
* @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',
'image' => 'Image',
'thumb' => 'Thumb',
'note' => 'Note',
'create_time' => 'Create Time',
'status' => 'Status',
'photocate_id' => 'Photocate',
'events_id' => 'Events',
'user_id' => 'User',
);
}
}
then in the controll:
$model->thumb=$thumbname;
yii keep saying:
CException
Description
Property "Photos.thumb" is not defined.
Source File
C:\xampp\htdocs\lib\framework\db\ar\CActiveRecord.php(122)
00110: * PHP setter magic method.
00111: * This method is overridden so that AR attributes can be accessed like properties.
00112: * @param string property name
00113: * @param mixed property value
00114: */
00115: public function __set($name,$value)
00116: {
00117: if($this->setAttribute($name,$value)===false)
00118: {
00119: if(isset($this->getMetaData()->relations[$name]))
00120: $this->_related[$name]=$value;
00121: else
00122: parent::__set($name,$value);
00123: }
00124: }
00125:
00126: /**
00127: * Checks if a property value is null.
00128: * This method overrides the parent implementation by checking
00129: * if the named attribute is null or not.
00130: * @param string the property name or the event name
00131: * @return boolean whether the property value is null
00132: * @since 1.0.1
00133: */
00134: public function __isset($name)
Stack Trace
#0 C:\xampp\htdocs\lib\framework\db\ar\CActiveRecord.php(122): CComponent->__set('thumb', NULL)
#1 C:\xampp\htdocs\protected\controllers\PhotosController.php(101): CActiveRecord->__set('thumb', NULL)
#2 C:\xampp\htdocs\lib\framework\web\actions\CInlineAction.php(32): PhotosController->actionCreate()
#3 C:\xampp\htdocs\lib\framework\web\CController.php(300): CInlineAction->run()
#4 C:\xampp\htdocs\lib\framework\web\filters\CFilterChain.php(129): CController->runAction(Object(CInlineAction))
#5 C:\xampp\htdocs\lib\framework\web\filters\CFilter.php(41): CFilterChain->run()
#6 C:\xampp\htdocs\lib\framework\web\CController.php(983): CFilter->filter(Object(CFilterChain))
#7 C:\xampp\htdocs\lib\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))
#8 C:\xampp\htdocs\lib\framework\web\filters\CFilterChain.php(126): CInlineFilter->filter(Object(CFilterChain))
#9 C:\xampp\htdocs\lib\framework\web\CController.php(283): CFilterChain->run()
#10 C:\xampp\htdocs\lib\framework\web\CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)
#11 C:\xampp\htdocs\lib\framework\web\CWebApplication.php(320): CController->run('create')
#12 C:\xampp\htdocs\lib\framework\web\CWebApplication.php(120): CWebApplication->runController('photos/create')
#13 C:\xampp\htdocs\lib\framework\base\CApplication.php(135): CWebApplication->processRequest()
#14 C:\xampp\htdocs\index.php(11): CApplication->run()
#15 {main}
i thought i have definded thumb, why yii still says thie error?
thanks!