PHP文章按日期(月日)SQL归档语句

yipeiwu_com6年前PHP代码库
复制代码 代码如下:

select FROM_UNIXTIME(pubtime, '%Y-%m') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m')

PHP文章按日期(日)SQL归档
复制代码 代码如下:

select FROM_UNIXTIME(pubtime, '%Y-%m-%d') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m-%d')

非时间戳日期格式归档(date_format格式化日期)
复制代码 代码如下:

select date_format(`post_date`,'%Y%m%d') as pubtime, count(*) as cnt from wp_posts where `post_status`='publish' group by date_format(`post_date`,'%Y%m%d') order by `ID` desc
select date_format(`post_date`,'%Y%m%d') as pubtime,date_format(`post_date`,'%m 月 %d 日') as shijian,count(*) as cnt from wp_posts where `post_status`='publish' group by date_format(`post_date`,'%Y%m%d') order by `ID` desc limit 0,7

相关文章

php通过淘宝API查询IP地址归属等信息

淘宝公司提供了一个很好用的IP地理信息查询接口。 在这里:http://ip.taobao.com/ TaobaoIPQuery2这个类将极大的简化相关的信息查询。 类 Taobao...

PHP iconv 解决utf-8和gb2312编码转换问题

终于皇天不负有心人,答案还是让我找到了。 网上的都是这样用的 复制代码 代码如下:$content = iconv("utf-8","gb2312",$content); 这样做其实也对...

php面向对象 字段的声明与使用

字段是用于描述类的么个方面的性质。 字段是用于描述类的某个方面的性质。它与一般的PHP 变量非常相似,只是有一些细微的差别,本节将介绍这些差别。这一节还将讨论如何声明和使用字段,下一节则...

PHP对象递归引用造成内存泄漏分析

通常来说,如果PHP对象存在递归引用,就会出现内存泄漏。这个Bug在PHP里已经存在很久很久了,先让我们来重现这个Bug,示例代码如下: <?php class Foo...

使用php统计字符串中中英文字符的个数

复制代码 代码如下:<?phpecho $str = "43fdf测试fdsfadaf43543543职工问防盗锁防盗锁5345gfdgd";preg_match_all("/[0...