- action : modified get_counter() function

- description : documentation added
This commit is contained in:
Saqib Razzaq 2016-03-02 22:51:12 -08:00
parent 50da7f9d03
commit 805f729d7f

View file

@ -4940,32 +4940,33 @@
/** /**
* function used to get counts from * Fetch total count for videos, photos and channels
* cb_counter table *
* @param : { string } { $section } { section to select count for }
* @param : { string } { $query } { query to fetch data against }
* @return : { integer } { $select[0]['counts'] } { count for requested field }
*/ */
function get_counter($section,$query)
{
if(!config('use_cached_pagin'))
return false;
function get_counter($section,$query) {
global $db; global $db;
if(!config('use_cached_pagin')) {
return false;
}
$timeRefresh = config('cached_pagin_time'); $timeRefresh = config('cached_pagin_time');
$timeRefresh = $timeRefresh*60; $timeRefresh = $timeRefresh*60;
$validTime = time()-$timeRefresh; $validTime = time()-$timeRefresh;
unset($query['order']); unset($query['order']);
$je_query = json_encode($query); $je_query = json_encode($query);
$query_md5 = md5($je_query); $query_md5 = md5($je_query);
$select = $db->select(tbl('counters'),"*","section='$section' AND query_md5='$query_md5' $select = $db->select(tbl('counters'),"*","section='$section' AND query_md5='$query_md5'
AND '$validTime' < date_added"); AND '$validTime' < date_added");
if($db->num_rows>0) if($db->num_rows>0) {
{
return $select[0]['counts']; return $select[0]['counts'];
}else } else {
return false; return false;
} }
}
/** /**
* Updates total count for videos, photos and channels * Updates total count for videos, photos and channels