Cakephp发现问题

时间:2011-09-02 07:38:38

标签: php cakephp cakephp-appmodel

我有一个交易表,在控制器中有一个字段开始日期我正在尝试下面的代码,并且在处理这些条件时它没有返回任何交易

以下是代码:

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'));

    }

我完全不知道为什么这不应该返回任何交易。

所有帮助表示赞赏

由于 戴夫

1 个答案:

答案 0 :(得分:2)

如果你打开debug level in CakePHP,它应该转出所用的查询。

检查为您的选择生成的SQL - 可能日期格式是问题。