Skip to content

Instantly share code, notes, and snippets.

@korrio
Created May 5, 2015 10:08
Show Gist options
  • Save korrio/9f58d889cd488648c9dc to your computer and use it in GitHub Desktop.
Save korrio/9f58d889cd488648c9dc to your computer and use it in GitHub Desktop.
SK_getVideosWithPPV
function SK_getVideosWithPPV($query,$numL = 0,$numM = 8,$sort='N'){
global $dbConnect;
$sql = '';
if(!empty($query)){
$query = SK_secureEncode($query);
$sql = "AND b.youtube_title LIKE '%".$query."%'";
}else{
$sql = "";
}
//A
//echo $sort;
if($sort=='N'){
$sortdata = 'order by b.time desc';
$query_one = "SELECT b.id,b.active,b.google_map_name,b.hidden,b.link_title,b.link_url,
b.media_id,b.clip_id,b.post_id,b.recipient_id,b.soundcloud_title,
b.soundcloud_uri,b.text,b.time,b.timeline_id,b.type1,b.type2,b.youtube_video_id,
b.youtube_title,b.youtube_description,b.view
{$query_like}
FROM " . DB_POSTS . " b
WHERE ((b.clip_id != 0 OR b.clip_id > 0) OR b.youtube_video_id != '')
AND b.type1='story'
AND b.active=1
AND b.hidden = 0 {$sql} {$sortdata} LIMIT ".$numL." , ".$numM;
}elseif($sort=='V'){
$sortdata = 'order by b.view desc';
$query_one = "SELECT b.id,b.active,b.google_map_name,b.hidden,b.link_title,b.link_url,
b.media_id,b.clip_id,b.post_id,b.recipient_id,b.soundcloud_title,
b.soundcloud_uri,b.text,b.time,b.timeline_id,b.type1,b.type2,b.youtube_video_id,
b.youtube_title,b.youtube_description,b.view
{$query_like}
FROM " . DB_POSTS . " as b
WHERE ((b.clip_id != 0 OR b.clip_id > 0) OR b.youtube_video_id != '')
AND b.type1='story'
AND b.active=1
AND b.hidden = 0 {$sortdata} LIMIT ".$numL." , ".$numM;
}elseif($sort=='L'){
$query_one = "select a.post_id as id,count(a.id) as total_like ,b.active,b.google_map_name,b.hidden,b.link_title,b.link_url,
b.media_id,b.clip_id,b.post_id,b.recipient_id,b.soundcloud_title,
b.soundcloud_uri,b.text,b.time,b.timeline_id,b.type1,b.type2,b.youtube_video_id,
b.youtube_title,b.youtube_description,b.view ,b.timestamp
from posts a inner join posts b on (a.post_id = b.id AND ((b.clip_id != 0 OR b.clip_id > 0) OR b.youtube_video_id != '') AND b.type1='story'
AND a.active=1
AND a.hidden = 0 )
where a.type2='like'
group by a.post_id
order by total_like desc LIMIT ".$numL.",".$numM;
}
$sql_query_one = mysqli_query($dbConnect, $query_one);
if (mysqli_num_rows($sql_query_one) > 0) {
while ($sql_fetch_one = mysqli_fetch_assoc($sql_query_one)) {
$videos[] = SK_getStoryMobile($sql_fetch_one["id"]);;
}
}
return $videos;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment