本文整理汇总了PHP中Video::find_by_sql方法的典型用法代码示例。如果您正苦于以下问题:PHP Video::find_by_sql方法的具体用法?PHP Video::find_by_sql怎么用?PHP Video::find_by_sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Video
的用法示例。
在下文中一共展示了Video::find_by_sql方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index($request)
{
$data = [];
$counts = [];
$counts['videos'] = Video::count();
$counts['users'] = User::count();
$counts['channels'] = UserChannel::count();
$counts['comments'] = Comment::count();
$counts['total_views'] = Video::sumViews();
$counts['channel_user_ratio'] = round($counts['channels'] / $counts['users'], 2);
$counts['videos_that_has_comments'] = Statistic::countVideosHavingComments();
$counts['channels_having_videos'] = Video::find_by_sql('SELECT count(DISTINCT poster_id) as count from `videos`')[0]->count;
$counts['part_of_commented_videos'] = round($counts['videos_that_has_comments'] / $counts['videos'] * 100, 2);
$counts['part_of_channels_having_videos'] = round($counts['channels_having_videos'] / $counts['channels'] * 100, 2);
$counts['user_1_channel'] = Statistic::countUserHavingChannels('= 1');
$counts['user_2_channel'] = Statistic::countUserHavingChannels('= 2');
$counts['user_3_channel'] = Statistic::countUserHavingChannels('= 3');
$counts['user_more3_channel'] = Statistic::countUserHavingChannels('> 3');
$counts['user_1_channel_part'] = round($counts['user_1_channel'] / $counts['users'] * 100, 2);
$counts['user_2_channel_part'] = round($counts['user_2_channel'] / $counts['users'] * 100, 2);
$counts['user_3_channel_part'] = round($counts['user_3_channel'] / $counts['users'] * 100, 2);
$counts['user_more3_channel_part'] = round($counts['user_more3_channel'] / $counts['users'] * 100, 2);
$data['counts'] = $counts;
return new ViewResponse('admin/statistic/index', $data);
}
示例2: getSubscriptionsVideosFromChannel
public function getSubscriptionsVideosFromChannel($channelId, $amount = 'nope')
{
$videos = [];
if ($amount != 'nope') {
$vidsToAdd = Video::find_by_sql("SELECT * FROM videos WHERE poster_id=? ORDER BY timestamp DESC LIMIT " . $amount, array($channelId));
} else {
$vidsToAdd = Video::find_by_sql("SELECT * FROM videos WHERE poster_id=? ORDER BY timestamp DESC", array($channelId));
}
return $vidsToAdd;
}
示例3: getSubscriptionsVideos
public static function getSubscriptionsVideos($userId, $amount = 'nope')
{
$videos = [];
$user = User::find_by_id($userId);
$sub_array = $user->getSubscribedChannelsAsList();
if (empty($sub_array)) {
return [];
//No sub
}
$sub_array = array_map(function ($v) {
return "'{$v}'";
}, $sub_array);
$subs = '(' . implode(', ', $sub_array) . ')';
if ($amount != 'nope') {
$vidsToAdd = Video::find_by_sql("SELECT * FROM videos WHERE visibility=2 AND poster_id IN " . $subs . " ORDER BY timestamp DESC LIMIT " . $amount);
} else {
$vidsToAdd = Video::find_by_sql("SELECT * FROM videos WHERE visibility=2 AND poster_id IN " . $subs . " ORDER BY timestamp DESC");
}
return $vidsToAdd;
}