添加新列后不创建记录


Yii not creating records after adding new columns

在我的web应用程序的数据库中,我有一个模型名为"ProducerOffer"。在使用Gii生成模型之后,我又创建了两个列,分别名为"booked_qty"answers"available_qty"。当我创建新的记录,它只是渲染从属性的空值

模型的代码

return array(
            array(' vegetable_id, offered_qty, unit_cost, unit_delivery_cost', 'required'),
            array(' offered_qty,  unit_delivery_cost, booking_status, booked_by, available_days', 'numerical', 'integerOnly'=>true),
            array('user_id', 'length', 'max'=>11),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('id,userName,user_id, vegetable_id, offered_qty,booked_qty,available_qty, unit_cost, unit_delivery_cost,  offered_date,  booking_status, booked_by, available_days', 'safe', 'on'=>'search'),
             array('booked_qty,available_qty',  'safe'),
        ); 

窗体

的代码
div style='padding-left:50px'>
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array('id'=>'producer-offer-form','enableAjaxValidation'=>false,)); ?>
<p class="help-block">Fields with <span class="required">*</span> are required.</p>
<?php
if(Yii::app()->user->type=="PRODUCER"){
 echo $form->errorSummary($model); 
 echo $form->dropDownList($model,'vegetable_id', CHtml::listData(Vegetable::model()->findAll(), 'id', 'name'), array('prompt'=>'Select Vegetable')); 
 echo $form->textFieldRow($model,'booked_quantity',array('class'=>'span5','maxlength'=>64)); 
 echo $form->textFieldRow($model,'available_quantity',array('class'=>'span5','maxlength'=>64)); 
 echo $form->textFieldRow($model,'unit_delivery_cost',array('class'=>'span5','maxlength'=>64)); 
}
if(Yii::app()->user->type==="CONSUMER"){
echo $form->textFieldRow($model,'offered_qty',array('class'=>'span5','maxlength'=>64));
}
?>
<div class="form-actions">
    <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'submit', 'type'=>'primary', 'label'=>$model->isNewRecord ? 'Create' : 'Save',)); ?>  
    <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'reset', 'type'=>'primary', 'label'=> 'Reset')); ?>
   <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'link', 'type'=>'primary', 'label'=> 'Cancel','url'=>Yii::app()->user->returnUrl,)); ?>
</div>
<?php $this->endWidget(); ?>
</div>

我该如何解决这个问题?

不,我编辑了问题,我在表格中添加了这些列。我只是添加了这些列,添加后我没有使用gii。我刚刚添加了数据库表中的列。

在我看来,你需要重新运行Gii Model Generator和一些CRUD Generator文件,运行Gii模型创建器将确保你的模型具有关于表结构的所有信息,以及它们与其他表的关系。CRUD生成器还将帮助确保为所有表列创建输入字段。