當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Article::load方法代碼示例

本文整理匯總了PHP中common\models\Article::load方法的典型用法代碼示例。如果您正苦於以下問題:PHP Article::load方法的具體用法?PHP Article::load怎麽用?PHP Article::load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在common\models\Article的用法示例。


在下文中一共展示了Article::load方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionCreate

 /**
  * Creates a new Article model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Article();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'categories' => ArticleCategory::find()->active()->all(), 'ads' => Ad::find()->all(), 'articles' => Article::find()->all()]);
     }
 }
開發者ID:Brother-Simon,項目名稱:yii2-starter-kit,代碼行數:14,代碼來源:ArticleController.php

示例2: actionCreate

 /**
  * Creates a new Article model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Article();
     $model->status = Article::STATUS_DISPLAY;
     if ($model->load(Yii::$app->request->post()) && $model->saveArticle()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
開發者ID:specialnote,項目名稱:myYii,代碼行數:15,代碼來源:ArticleController.php

示例3: actionCreate

 /**
  * Creates a new Article model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Article();
     $model->load(Yii::$app->request->post());
     $model->image = UploadedFile::getInstance($model, 'image');
     if ($model->save()) {
         $this->saveImage($model);
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
開發者ID:horechek,項目名稱:nnews,代碼行數:17,代碼來源:ArticleController.php

示例4: actionCreate

 /**
  * Creates a new ArticleDownload model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($cat_id)
 {
     $model = new ArticleDownload();
     $Article = new Article();
     $postData = Yii::$app->request->post();
     if ($model->load($postData) && $Article->load($postData) && $Article->save() && $model->addData($Article->article_id)) {
         Yii::$app->session->setFlash('success', '添加成功');
         return $this->redirect(['article/index']);
     } else {
         Yii::$app->view->params['meta_title'] = '添加文章';
         return $this->render('create', ['model' => $model, 'Article' => $Article]);
     }
 }
開發者ID:wordnews,項目名稱:wei_shop,代碼行數:18,代碼來源:DownloadController.php

示例5: actionCreate

 /**
  * Creates a new Section model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Article();
     $model->scenario = 'create';
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if (Yii::$app->request->post('isPublish', 0) == 1) {
             $model->status = Section::STATUS_PUBLISH;
         }
         $model->create();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         Yii::$app->session->set('KCFINDER', ['disabled' => false, 'uploadURL' => '/upload', 'uploadDir' => '../../../backend/web/upload']);
         return $this->render('create', ['model' => $model]);
     }
 }
開發者ID:tqsq2005,項目名稱:digpage,代碼行數:20,代碼來源:ArticleController.php

示例6: actionCreate

 public function actionCreate()
 {
     $this->layout = '/adminka';
     $model = new Article();
     //        if (Yii::$app->request->post()) {
     //
     //        $model->load(Yii::$app->request->post());
     //        $model->validate();
     //        vd($model->getErrors());
     //    }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
開發者ID:kotmonstr,項目名稱:kotmonstr,代碼行數:16,代碼來源:DefaultController.php

示例7: actionCreate

 /**
  * Creates a new Article model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Article();
     $dataModel = new ArticleData();
     if ($model->load(Yii::$app->request->post()) && $dataModel->load(Yii::$app->request->post())) {
         $isValid = $model->validate();
         if ($isValid) {
             $model->save(false);
             $dataModel->id = $model->id;
             $isValid = $dataModel->validate();
             if ($isValid) {
                 $dataModel->save(false);
                 return $this->redirect(['index']);
             }
         }
     }
     return $this->render('create', ['model' => $model, 'dataModel' => $dataModel]);
 }
開發者ID:zhangsong,項目名稱:yii,代碼行數:23,代碼來源:ArticleController.php

示例8: actionArtadd

 public function actionArtadd()
 {
     $cate = ArticleCate::find()->all();
     //類別數據填充
     //添加文章
     $model = new Article();
     if ($model->load(Yii::$app->request->post())) {
         //上傳文章封麵圖
         if ($_FILES['Article']['name']['cover']) {
             $img = Yii::$app->imgload->UploadPhoto($model, 'uploads/article/', 'cover');
             $model->cover = $img;
             if ($model->save()) {
                 Yii::$app->getSession()->setFlash('info', '添加成功!');
                 return $this->redirect(['articlelist']);
             } else {
                 Yii::$app->getSession()->setFlash('info', '添加失敗!');
                 @unlink($img);
                 return $this->redirect(['articlelist']);
             }
             //不上傳文章封麵圖
         } else {
             if ($model->save()) {
                 Yii::$app->getSession()->setFlash('info', '添加成功!');
                 return $this->redirect(['articlelist']);
             }
         }
     }
     return $this->render('artadd', ['cate' => $cate, 'model' => $model]);
 }
開發者ID:dlpc,項目名稱:yii2-plane,代碼行數:29,代碼來源:ArticleController.php


注:本文中的common\models\Article::load方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。