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


PHP Article::findOne方法代码示例

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


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

示例1: actionView

 public function actionView($id)
 {
     $article = Article::findOne($id);
     $comment = new Comment();
     $comments = $article->comments;
     return $this->render("view", ["article" => $article, "comment" => $comment, "comments" => $comments]);
 }
开发者ID:horechek,项目名称:nnews,代码行数:7,代码来源:ArticleController.php

示例2: findModel

 /**
  * Finds the Article model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Article the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Article::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:Brother-Simon,项目名称:yii2-starter-kit,代码行数:15,代码来源:ArticleController.php

示例3: actionAddStars

 public function actionAddStars($id)
 {
     if (\Yii::$app->request->isAjax) {
         $model = Article::findOne($id);
         $model->addStars();
         return json_encode(1);
     }
 }
开发者ID:buuug7,项目名称:game4039,代码行数:8,代码来源:ArticleController.php

示例4: findModel

 /**
  * Finds the ArticleDownload model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ArticleDownload the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     $ArticleDownload = ArticleDownload::findOne($id);
     $Article = Article::findOne($id);
     if ($ArticleDownload !== null && $Article !== null) {
         return ['ArticleDownload' => $ArticleDownload, 'Article' => $Article];
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:wordnews,项目名称:wei_shop,代码行数:17,代码来源:DownloadController.php

示例5: actionDetail

 public function actionDetail($id)
 {
     if (!($article = Article::findOne($id))) {
         throw new NotFoundHttpException('ID 为 ' . $id . ' 的文章没有找到');
     }
     //文章标签
     $tags = $article->getArticleTag();
     //相关文章
     return $this->render('detail', ['article' => $article, 'tags' => $tags]);
 }
开发者ID:specialnote,项目名称:myYii,代码行数:10,代码来源:ArticleController.php

示例6: init

 public function init()
 {
     parent::init();
     if ($this->id) {
         $this->_item = Article::findOne($this->id);
     } else {
         throw new InvalidParamException(\Yii::t('front', 'No required parameter given') . ' - id');
     }
     if (!$this->articleType) {
         $this->articleType = 'normal';
     }
 }
开发者ID:czechcamus,项目名称:dasport,代码行数:12,代码来源:NewsletterArticle.php

示例7: deleteArticle

 /**
  * Deletes Article
  * @throws \Exception
  */
 public function deleteArticle()
 {
     /** @var $article Article */
     if ($article = Article::findOne($this->item_id)) {
         $article->removeAllTagValues();
         $article->delete();
     }
 }
开发者ID:czechcamus,项目名称:dasport,代码行数:12,代码来源:ArticleForm.php

示例8: init

 public function init()
 {
     parent::init();
     $this->_article = Article::findOne($this->id);
 }
开发者ID:czechcamus,项目名称:dasport,代码行数:5,代码来源:NewsletterArticle.php

示例9: findModel

 protected function findModel($id)
 {
     if (($model = Article::findOne($id)) !== null) {
         return $model;
     } else {
         // 跳转到 :您访问到页面不存在
     }
 }
开发者ID:codekissyoung,项目名称:filmfest,代码行数:8,代码来源:ArticleController.php

示例10: actionArtedit

 public function actionArtedit()
 {
     if (Yii::$app->request->get('id')) {
         $id = Yii::$app->request->get('id');
         $cate = ArticleCate::find()->all();
         //类别数据填充
         $model = Article::findOne($id);
         return $this->render('artedit', ['id' => $id, 'cate' => $cate, 'model' => $model]);
     } elseif (Yii::$app->request->post('id')) {
         $id = Yii::$app->request->post('id');
         $model = Article::findOne($id);
         $cover = $model->cover;
         if ($model === null) {
             Yii::$app->getSession()->setFlash("info", '编辑失败');
             return $this->redirect(['articlelist']);
         }
         if ($model->load(Yii::$app->request->post())) {
             if ($_FILES['Article']['name']['cover']) {
                 //删除原图片
                 if ($cover) {
                     unlink($cover);
                 }
                 //更新新图片
                 $img = Yii::$app->imgload->UploadPhoto($model, 'uploads/article/', 'cover');
                 $model->cover = $img;
             } else {
                 $model->cover = $cover;
             }
             if ($model->save()) {
                 Yii::$app->getSession()->setFlash('info', '编辑成功!');
                 return $this->redirect(['articlelist']);
             } else {
                 Yii::$app->getSession()->setFlash('info', '编辑失败!');
                 @unlink($img);
                 return $this->redirect(['articlelist']);
             }
         }
     }
 }
开发者ID:dlpc,项目名称:yii2-plane,代码行数:39,代码来源:ArticleController.php

示例11: findModel

 protected function findModel($id)
 {
     if (($model = Article::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('您要访问的页面不存在!');
     }
 }
开发者ID:codekissyoung,项目名称:filmfest,代码行数:8,代码来源:VideoController.php

示例12: closed

    echo Article::findOne(['id' => $model['recommend2_id']])->title;
    ?>
</p>
      </a></li>
  <?php 
}
?>
  <?php 
if (!empty($model['recommend3_id'])) {
    ?>
    <li><a href="<?php 
    echo \yii\helpers\Url::toRoute('/article/' . $model['recommend3_id'] . '-' . \Yii::$app->user->id);
    ?>
">
      <p><?php 
    echo Article::findOne(['id' => $model['recommend3_id']])->title;
    ?>
</p>
      </a></li>
  <?php 
}
?>
  </ul>
</div>
<div class="wycs"></div>
<script>
function closed()
{
 var aaa=document.getElementById("ad");
 aaa.style.display="none"
}
开发者ID:Brother-Simon,项目名称:yii2-starter-kit,代码行数:31,代码来源:index.php


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