我有一个交易表,在控制器中有一个字段开始日期我正在尝试下面的代码,当有这些条件的交易时它不会返回任何交易
这是代码:
function todays_deal($CitySlug = null) {
$city = $this->City->find('first', array('conditions' => array('City.slug' => $CitySlug)));
$CityID = $city['City']['id'];
$now = date('Y-m-d H:i:s');
$conditions = array(
'Deal.city_id' => $CityID,
'Deal.type' => 'F',
'Deal.start >=' => $now
);
$deal = $this->Deal->find('first',array('conditions'=> $conditions, 'order' => 'Deal.start DESC'));
$left = array();
$now = time();
//Change dates to timestamp
$end = strtotime($deal['Deal']['end']);
$start = strtotime($deal['Deal']['start']);
if($end < $start){
$end = $start;
}
$diff_time = $left_time = $end - $now;
if ($start >= $now ) {
$diff_time = $left_time = $start - $now;
}
$left_day = floor($diff_time/86400);
$left_time = $left_time % 86400;
$left_hour = floor($left_time/3600);
$left_time = $left_time % 3600;
$left_minute = floor($left_time/60);
$left_time = $left_time % 60;
$this->set(compact('deal', 'left_day', 'left_hour', 'left_minute', 'left_time', 'now', 'diff_time'));
}
我完全不知道为什么这没有返回任何应有的交易。
所有帮助表示赞赏
谢谢戴夫