Php 当我在yii中更新时,如何在数据库中插入新行? 这是我的密码

Php 当我在yii中更新时,如何在数据库中插入新行? 这是我的密码,php,yii,Php,Yii,大家能帮帮我吗?我希望我的系统在yii框架中更新时插入新记录 public function actionUpdate($id)<br/> { $model=$this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST[

大家能帮帮我吗?我希望我的系统在yii框架中更新时插入新记录

public function actionUpdate($id)<br/>
{
    $model=$this->loadModel($id);

    // Uncomment the following line if AJAX validation is needed
    // $this->performAjaxValidation($model);

    if(isset($_POST['Entrydata']))
    {
        $_POST['Entrydata']['photo'] = $model->photo;
        $model->attributes=$_POST['Entrydata'];
        $uploadedFile = CUploadedFile::getInstance($model,'photo');

        if($model->save())
        {

            if(!empty($uploadedFile))  // check if uploaded file is set or not
            {
             $uploadedFile->saveAs(Yii::app()->basePath.'/../images/'.$model->photo); // image will uplode to rootDirectory/banner/
            }  
            $this->redirect(array('view','id'=>$model->id_entry)); 
        }


    }

    $this->render('create',array(
        'model'=>$model,
    ));
}

保存前取消设置属性

 $model->unsetAttributes(array("id_entry"));

public function actionUpdate($id)
{ 
    $model=$this->loadModel($id);

    // Uncomment the following line if AJAX validation is needed
    // $this->performAjaxValidation($model);

    if(isset($_POST['Entrydata']))
    {
        $_POST['Entrydata']['photo'] = $model->photo;
        $model->attributes=$_POST['Entrydata'];
        $uploadedFile = CUploadedFile::getInstance($model,'photo');

         // Unset Primary Key value.
         $model->unsetAttributes(array("id_entry"));

        if($model->save())
        {

            if(!empty($uploadedFile))  // check if uploaded file is set or not
            {
             $uploadedFile->saveAs(Yii::app()->basePath.'/../images/'.$model->photo); // image will uplode to rootDirectory/banner/
            }  
            $this->redirect(array('view','id'=>$model->id_entry)); 
        }


    }

    $this->render('create',array(
        'model'=>$model,
    ));
}