/** * 编辑 */ public function actionEdit($id) { $model = parent::_model(new Article(), $id); $addonarticle = parent::_model(new Addonarticle(), $id); if (isset($_POST['Article'])) { $transaction = Yii::app()->db->beginTransaction(); try { $model->attributes = $_POST['Article']; if (!$model->save()) { Tool::logger('article', var_export($model->getErrors(), true)); throw new CException('文章更新失败'); } $addonarticle->attributes = $_POST['Addonarticle']; if (!$addonarticle->save()) { Tool::logger('article', var_export($addonarticle->getErrors(), true)); throw new CException('文章附表更新失败'); } $this->redirect(array('list')); } catch (Exception $e) { Tool::logger('article', $e->getMessage()); $transaction->rollback(); } } $this->render('edit', array('model' => $model, 'addonarticle' => $addonarticle)); }