本文整理汇总了PHP中common\models\Post::findByMySqlId方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::findByMySqlId方法的具体用法?PHP Post::findByMySqlId怎么用?PHP Post::findByMySqlId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\Post
的用法示例。
在下文中一共展示了Post::findByMySqlId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}