Home > php教程 > php手册 > thinkphp3.1query方法对时间格式处理技巧

thinkphp3.1query方法对时间格式处理技巧

WBOY
Release: 2016-06-06 19:39:37
Original
1165 people have browsed it

thinkphp3.1中的query无法对时间格式进行预处理。现在提供一种技巧写法。将%Y-%m-%d当变量传入sql中。不要直接写,否则报错。 $sql=" select * from (select * from y_a where id='%s' and datatime between %d and %d order by datatime desc) as A group b

thinkphp3.1中的query无法对时间格式进行预处理。现在提供一种技巧写法。将%Y-%m-%d当变量传入sql中。不要直接写,否则报错。

 $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'));
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template