致命错误:调用未定义的方法stdClass :: save()

时间:2012-06-07 06:48:51

标签: php model yii

当我需要更新时,我收到了这个答案。我应该怎么做?

public function actionUpdate($id)
{       
    if(isset($_POST['submit']))
    {
        $recruit = Recruit::model()->findByPk($_POST['pid']);
        $recruit->title = $_POST['title'];
        $test->save();
            $this->redirect(array('admin','id'=>$id));              
    }

    $this->render('update',array(
        'model'=>$this->loadModel($_POST['pid']),
        'id'=>$id,
        'pid'=>$_POST['pid'],
    ));
}

1 个答案:

答案 0 :(得分:5)

没有创建$test类实例,我认为您必须使用$recruit

 $test->save();
 //to
 $recruit->save();