本文整理匯總了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;
}