Hello guys,
i hope this is not a bug in Yii, but i have a model:
/**
* This is the model class for table "errorLog".
*
* The followings are the available columns in table 'errorLog':
* @property integer $id
* @property string $text
* @property integer $type
* @property string $createDate
* @property string $subject
*/
class ErrorLog extends CActiveRecord
{
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'errorLog';
}
/**
* @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('text, type, subject', 'required'),
array('type', 'numerical', 'integerOnly'=>true),
array('subject', 'length', 'max'=>120),
array('createDate', 'safe'),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, text, type, createDate, subject', 'safe', 'on'=>'search'),
);
}
And i am trying to create and save one instance:
$error = new ErrorLog();
$error->type = 27;
$error->text = Translate::t('error','27',$email->id);
$error->save();
And i am getting following error:
exception 'CException' with message 'Property "ErrorLog.subject" is not defined.' in /var/yii-framework/framework/base/CComponen
t.php:130
Stack trace:
#0 /var/yii-framework/framework/db/ar/CActiveRecord.php(145): CComponent->__get('subject')
#1 /var/yii-framework/framework/validators/CStringValidator.php(79): CActiveRecord->__get('subject')
#2 /var/yii-framework/framework/validators/CValidator.php(213): CStringValidator->validateAttribute(Object(ErrorLog), 'subject')
#3 /var/yii-framework/framework/base/CModel.php(159): CValidator->validate(Object(ErrorLog), NULL)
#4 /var/yii-framework/framework/db/ar/CActiveRecord.php(805): CModel->validate(NULL)
#5 /var/www/ekuskov-admin/protected/commands/SendEmailsCommand.php(26): CActiveRecord->save()
#6 /var/yii-framework/framework/console/CConsoleCommandRunner.php(71): SendEmailsCommand->run(Array)
#7 /var/yii-framework/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner->run(Array)
#8 /var/yii-framework/framework/base/CApplication.php(180): CConsoleApplication->processRequest()
#9 /var/www/ekuskov-admin/protected/cron.php(20): CApplication->run()
#10 {main}root@dev:~# php /var/www/ekuskov-admin/protected/cron.php sendEmails
A screenshot of the database is attached! The field exists!
Thanks for helping!