帝國(guó)CMS按小時(shí)發(fā)布文章數(shù)的統(tǒng)計(jì)(詳細(xì)說明)
時(shí)間: 2024-02-25 09:30
閱讀: 次
作者:素材無憂網(wǎng)
按照小時(shí)顯示更新數(shù)量
用sql調(diào)用
6小時(shí):=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_表 where newstime>UNIX_TIMESTAMP()-6*3600")?>
12小時(shí):=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_表 where newstime>UNIX_TIMESTAMP()-12*3600")?>
24小時(shí):=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_表 where newstime>UNIX_TIMESTAMP()-24*3600")?>
一個(gè)星期:=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_表 where newstime>UNIX_TIMESTAMP()-86400*7")?>
一個(gè)月:=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_表 where newstime>UNIX_TIMESTAMP()-86400*30")?>
靈動(dòng)標(biāo)簽調(diào)用
6小時(shí):[e:loop={'select count(*) as total from [!db.pre!]ecms_表 where newstime>UNIX_TIMESTAMP()-6*3600',0,24,0}]=$bqr[total]?>[/e:loop]
12小時(shí):[e:loop={'select count(*) as total from [!db.pre!]ecms_表 where newstime>UNIX_TIMESTAMP()-12*3600',0,24,0}]=$bqr[total]?>[/e:loop]
24小時(shí):[e:loop={'select count(*) as total from [!db.pre!]ecms_表 where newstime>UNIX_TIMESTAMP()-24*3600',0,24,0}]=$bqr[total]?>[/e:loop]
一個(gè)星期:[e:loop={'select count(*) as total from [!db.pre!]ecms_表 where newstime>UNIX_TIMESTAMP()-86400*7',0,24,0}]=$bqr[total]?>[/e:loop]
一個(gè)月:[e:loop={'select count(*) as total from [!db.pre!]ecms_表 where newstime>UNIX_TIMESTAMP()-86400*30',0,24,0}]=$bqr[total]?>[/e:loop]
12*3600即12小時(shí)
86400*7即7天
----------------------------------------------------------------------------------
統(tǒng)計(jì)昨天發(fā)表的文章數(shù)量
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
?>
[e:loop={"select count(*) as total from [!db.pre!]ecms_news where newstime BETWEEN $beginYesterday and $endYesterday",1,24,0}]=$bqr[total]?>[/e:loop] 篇
----------------------------------------------------------------------------------
當(dāng)前欄目本周更新:
=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_news where classid='$GLOBALS[navclassid]' and newstime >UNIX_TIMESTAMP()-86400*7")?>
注釋:按欄目統(tǒng)計(jì)一周發(fā)布文章數(shù) 加 classid='欄目id'
按當(dāng)前欄目一周發(fā)布文章數(shù) 加 classid='$GLOBALS[navclassid]'
//php獲取今日開始時(shí)間戳和結(jié)束時(shí)間戳
$beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
$endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
//php獲取昨日起始時(shí)間戳和結(jié)束時(shí)間戳 (即:前一天)
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
//調(diào)取這兩天(包括今天):(修改昨天)--date('d')-1:這兩天 、date('d')-2:這三天、以此類推(注意:$beginYesterday、$endYesterday這兩個(gè)未改動(dòng),還是沿用的昨天的名稱)
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
//調(diào)取前兩天(修改昨天)--date('d')-2:前兩天 、date('d')-3:前三天、以此類推(注意:$beginYesterday、$endYesterday這兩個(gè)未改動(dòng),還是沿用的昨天的名稱)
$beginYesterday=mktime(0,0,0,date('m'),date('d')-2,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
//php獲取上周起始時(shí)間戳和結(jié)束時(shí)間戳
$beginLastweek=mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y'));
$endLastweek=mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y'));
//php獲取本周起始時(shí)間戳和結(jié)束時(shí)間戳
$beginThisweek=mktime(0,0 ,0,date("m"),date("d")-date("w")+1,date("Y"));
$endThisweek=mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
//php獲取上月起始時(shí)間戳和結(jié)束時(shí)間戳
$beginLastmonth=mktime(0,0,0,date("m")-1,1,date("Y"))
$endLastmonth=mktime(23,59,59,date("m"),0,date("Y"))
//php獲取本月起始時(shí)間戳和結(jié)束時(shí)間戳
$beginThismonth=mktime(0,0,0,date('m'),1,date('Y'));
$endThismonth=mktime(23,59,59,date('m'),date('t'),date('Y'))