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

24小时发布的新文章:
86400 是 3600 * 24,就是24小时发布的新文章。
[sql]select count(id)+0 as total from dede_archives where UNIX_TIMESTAMP() – pubdate < 86400 and arcrank >0;[/sql]

任意日期发布的最新文章:
[sql]SELECT count(ID) as count from dede_archives where pubdate > UNIX_TIMESTAMP( FROM_UNIXTIME(UNIX_TIMESTAMP(), ‘%Y-%m-%d 00:00:00’)) limit 1;[/sql]

任意日期审核通过的最新文章
[sql]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;[/sql]

获取当日的零时时间:
[sql]FROM_UNIXTIME(UNIX_TIMESTAMP(), ‘%Y-%m-%d 00:00:00’)[/sql]

获取当时零时时间戳:
[sql]UNIX_TIMESTAMP( FROM_UNIXTIME(UNIX_TIMESTAMP(), ‘%Y-%m-%d 00:00:00’))[/sql]

当天发布的最新文章:
[sql]SELECT count(ID) as count from dede_archives where to_days(curdate())=to_days(from_unixtime(pubdate)) limit 1;[/sql]
这里使用 to_days(curdate())=to_days(from_unixtime(pubdate)),使用起来比较方便,资源占用也少,在只查询当天的文档时,推荐使用。

发表评论

回复 优酷影音 取消回复

评论列表(2)