当前位置: 首页>>代码示例>>PHP>>正文


PHP Page::findOne方法代码示例

本文整理汇总了PHP中app\models\Page::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::findOne方法的具体用法?PHP Page::findOne怎么用?PHP Page::findOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Page的用法示例。


在下文中一共展示了Page::findOne方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: findModel

 protected function findModel($id)
 {
     if (($model = Page::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:phucnv206,项目名称:pharma,代码行数:8,代码来源:PageController.php

示例2: actionView

 /**
  * Displays a single Cms model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $pagedata = Page::findOne($model->pageid);
     $cmspoaitiondata = Cmsposition::findOne($model->cmspositionid);
     $model->pageid = $pagedata->name;
     $model->cmspositionid = $cmspoaitiondata->name;
     //$model->imgurl = Yii::$app->request->hostInfo.'/'.$model->imgurl;
     return $this->render('view', ['model' => $model]);
 }
开发者ID:njxuquan,项目名称:baby,代码行数:15,代码来源:CmsController.php

示例3: actionDelete

 /**
  * @param $id
  * @return \yii\web\Response
  * @throws NotFoundHttpException
  * @throws \Exception
  */
 public function actionDelete($id)
 {
     /** @var Page $model */
     $model = Page::findOne($id);
     if (!$model) {
         throw new NotFoundHttpException();
     }
     $model->delete();
     return $this->redirect(['list']);
 }
开发者ID:vetoni,项目名称:toko,代码行数:16,代码来源:PageController.php

示例4: run

 public function run()
 {
     if (strpos(\Yii::$app->request->url, "view-post")) {
         $post = Post::findOne(\Yii::$app->request->get('id'));
         $current_page = $post->page;
     } else {
         if (strpos(\Yii::$app->request->url, "view-album")) {
             $photo = Photo::findOne(\Yii::$app->request->get('id'));
             $current_page = $photo->page;
         } else {
             $slug = \Yii::$app->request->get('slug');
             $current_page = Page::find()->where(['slug' => $slug])->one();
         }
     }
     $parent = $current_page->parent_id == 0 ? null : Page::findOne($current_page->parent_id);
     return $this->render('breadCrumb', ['parent' => $parent, 'current_page' => $current_page]);
 }
开发者ID:sanmaowang,项目名称:ycjl,代码行数:17,代码来源:Breadcrumb.php

示例5: getParent

 public function getParent()
 {
     return Page::findOne(['id' => $this->parent_id]);
 }
开发者ID:sanmaowang,项目名称:ycjl,代码行数:4,代码来源:Page.php

示例6: findModelBySlug

 /**
  * Finds the Page model based on its slug value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $slug
  * @return Page the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModelBySlug($slug)
 {
     if (($model = Page::findOne(['slug' => $slug])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:andreyvaslv,项目名称:crb,代码行数:15,代码来源:PageController.php

示例7: actionViewPage

 public function actionViewPage($id)
 {
     $page = Page::findOne($id);
     return $this->redirect(['site/page', 'slug' => $page->slug]);
 }
开发者ID:sanmaowang,项目名称:ycjl,代码行数:5,代码来源:SiteController.php

示例8: actionCreate

 /**
  * Creates a new Photo model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Photo();
     $request = Yii::$app->request;
     $page_id = $request->get('page_id');
     $model->create_date = time();
     $model->update_date = time();
     if ($model->load(Yii::$app->request->post())) {
         $model->page_id = $page_id;
         $model->parent_id = 0;
         $model->create_date = strtotime($model->create_date);
         $model->update_date = strtotime($model->update_date);
         if ($model->save()) {
             return $this->redirect(['view', 'id' => $model->id, 'page_id' => $page_id]);
         }
     }
     $page = Page::findOne($page_id);
     return $this->render('create', ['model' => $model, 'page_id' => $page_id, 'page' => $page]);
 }
开发者ID:sanmaowang,项目名称:ycjl,代码行数:24,代码来源:PhotoController.php


注:本文中的app\models\Page::findOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。