public function run()
 {
     DB::statement("TRUNCATE TABLE business_categories");
     $category = new BusinessCategory();
     $category->name = 'Category one';
     $category->created_at = new DateTime();
     $category->updated_at = new DateTime();
     $category->save();
     $category = new BusinessCategory();
     $category->name = 'Category two';
     $category->created_at = new DateTime();
     $category->updated_at = new DateTime();
     $category->save();
 }
示例#2
0
 public function actionCreate()
 {
     $model = new BusinessCategory();
     if (isset($_POST['BusinessCategory']) || isset($_POST['Page'])) {
         try {
             if ($model->save()) {
                 $this->redirect(array('view', 'id' => $model->id));
             }
         } catch (Exception $e) {
             $model->addError('', $e->getMessage());
         }
     } elseif (isset($_GET['BusinessCategory'])) {
         $model->attributes = $_GET['BusinessCategory'];
     }
     $this->render('create', array('model' => $model));
 }