当我需要更新时,我收到了这个答案。我应该怎么做?
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'],
));
}
答案 0 :(得分:5)
没有创建$test
类实例,我认为您必须使用$recruit
$test->save();
//to
$recruit->save();