我试试这个,但它不起作用
{
'conditions' => array('Graph.hid' => $hid, 'DATE(Graph.created) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)', 'Graph.number'=>2)
}
实际上需要前一天的当前时间数据。 谁能帮我?提前谢谢。
答案 0 :(得分:1)
如果您有DATETIME,可以在查询中找到BETWEEN(find):
$yesterday = date("Y-m-d", (time()-86400));
$query = 'SELECT * FROM table WHERE registration between '."'$yesterday 00:00:00'".' and '. "'$yesterday 23:59:59'";
蛋糕之间是:
array('Post.read_count BETWEEN ? AND ?' => array(1,10))
计算最后一天的其他方法:
date("Y-m-d", time() - 86400);
date("Y-m-d", strtotime("yesterday"));
date("Y-m-d", strtotime("-1 day"));