DEDEcms使用SQL获得当天已审核的文章总数

by 尘缘 on 03月 5th, 2010 // Filed Under → DEDE, MySQL

24小时发布的新文章:
86400 是 3600 * 24,就是24小时发布的新文章。

select count(id)+0 as total from dede_archives where UNIX_TIMESTAMP() - pubdate < 86400 and arcrank >0;

任意日期发布的最新文章:

SELECT count(ID) as count from dede_archives where pubdate > UNIX_TIMESTAMP( FROM_UNIXTIME(UNIX_TIMESTAMP(), '%Y-%m-%d 00:00:00'))  limit 1;

任意日期审核通过的最新文章

SELECT count(ID) as count from dede_archives where pubdate > UNIX_TIMESTAMP( FROM_UNIXTIME(UNIX_TIMESTAMP(), '%Y-%m-%d 00:00:00')) and arcrank >  limit 1;

获取当日的零时时间:

FROM_UNIXTIME(UNIX_TIMESTAMP(), '%Y-%m-%d 00:00:00')

获取当时零时时间戳:

UNIX_TIMESTAMP( FROM_UNIXTIME(UNIX_TIMESTAMP(), '%Y-%m-%d 00:00:00'))

当天发布的最新文章:

SELECT count(ID) as count from dede_archives where to_days(curdate())=to_days(from_unixtime(pubdate))  limit 1;

这里使用 to_days(curdate())=to_days(from_unixtime(pubdate)),使用起来比较方便,资源占用也少,在只查询当天的文档时,推荐使用。

你可以任意转摘“DEDEcms使用SQL获得当天已审核的文章总数”,但请保留本文出处和版权信息。
作者:尘缘,QQ:130775,来源:http://www.4wei.cn/archives/1000454

有 2 条评论啦

Posted on 2010年04月1号 at 23:01:30

优酷影音 :

支持一下

Posted on 2010年04月5号 at 16:06:17

迅扬网建 :

学习了。



走过路过,千万不要飞过,那是鸟人: