thinkphp3.1中的query无法对时间格式进行预处理。现在提供一种技巧写法。将%Y-%m-%d当变量传入sql中。不要直接写,否则报错。 1. [代码] [PHP]代码 $sql=" select * from (select * from y_a where id='%s'
1. [代码][PHP]代码
$sql=" select * from (select * from y_a where id='%s' and datatime between %d and %d order by datatime desc) as A group by from_unixtime(datatime,'%s') order by datatime ASC limit 30"; $data=$this->query($sql,array($xywy_userid,$starttime,$endtime,'%Y-%m-%d'));