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


PHP Post::findByUrl方法代码示例

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


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

示例1: actionCreate

 public function actionCreate()
 {
     //$start = microtime();
     parent::actionIndex();
     $postId = (int) Yii::$app->getRequest()->post('post_id');
     $url = Yii::$app->getRequest()->post('post_url');
     if ($postId && $postId != "undefined") {
         $post = Post::findByMySqlId($postId, Yii::$app->getRequest()->post('project_id'));
     } elseif ($url) {
         $post = Post::findByUrl($url);
     } else {
         throw new ForbiddenHttpException("Param url is not provided", self::CODE_NO_URL);
     }
     $postViewModel = new PostView();
     $postViewModel->load(Yii::$app->getRequest()->getBodyParams(), '');
     $postViewModel->post_id = $postId;
     $postViewModel->save();
     if ($post) {
         $total = PostView::find()->where(array('project_id' => (int) Yii::$app->getRequest()->post('project_id'), 'post_id' => $postId))->count();
         //$unique = PostView::find()->where(array('project_id' => (int)Yii::$app->getRequest()->post('project_id'), 'post_id' => (int)$post->getID()))->distinct("uid");
         $response = array('total' => $total, 'unique' => (int) $post->views['unique']);
         $post->views = $response;
         $post->save();
     } else {
         $total = PostView::find()->where(array('project_id' => (int) Yii::$app->getRequest()->post('project_id'), 'post_id' => $postId, 'post_url' => $url))->count();
         $response = array('total' => $total, 'unique' => 0);
     }
     //echo microtime() - $start;
     return $response;
 }
开发者ID:veretilosergei1985,项目名称:learni,代码行数:30,代码来源:ViewController.php

示例2: actionCreate

 public function actionCreate()
 {
     parent::actionIndex();
     if (!($url = Yii::$app->getRequest()->post('url'))) {
         throw new ForbiddenHttpException("Param url is not provided", self::CODE_NO_URL);
     }
     if (substr($url, -1) != "/") {
         $url = $url . "/";
     }
     $socialShare = new SocialShare($url);
     $post = Post::findByUrl($url);
     if (!$post) {
         throw new ForbiddenHttpException("Post not found", self::CODE_NO_POST);
     }
     return $socialShare->save($post);
 }
开发者ID:veretilosergei1985,项目名称:learni,代码行数:16,代码来源:ShareController.php


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