public function actionAddCategory() { $model = new FaqCategory(); $model->user_id = $this->user->id; $model->date = time(); $model->status = FaqCategory::STATUS_HIDE; // $model->unsetAttributes(); if (isset($_POST['FaqCategory'])) { $model->attributes = $_POST['FaqCategory']; if ($model->save()) { Yii::app()->user->setFlash('success', '新加FAQ分类成功'); $this->redirect(array('/board/faq/category')); } } $model->formatDate(); $this->render('editCategory', array('model' => $model)); }
public function actionCopy() { exit; Yii::import('feedback.models.*'); $faqGroups = FaqGroup::model()->findAll(array('order' => 't.id ASC')); foreach ($faqGroups as $key => $group) { $category = new FaqCategory(); $category->id = $group->id; $category->title = $group->title; $category->sort = $group->sort * 10; $category->status = $group->status; $category->parent_id = 0; if ($category->save()) { echo $category->title . ' - success<br />'; } else { echo $category->title . ' - error<br />'; var_dump($category->getErrors()); } echo '<hr>'; } }