cakephp 复杂查询

        $now = time();
        $this->CardTypeInfos->recursive = -1;
        $conditions = [
            'seller_id'=>SELLER_ID,
            'del_state'=>1,

            'or'=>[
               [
                   'date_info_type'=>2,
               ],
                [
                    'date_info_type'=>1,
                    'begin >= '=>$now,
                    'end <= '=>$now,
                ],

            ]
        ];
        $coupons_list = $this->CardTypeInfos->find('list', array('conditions' => $conditions, 'fields' => array('id', 'title')));
        echo $this->debugsql('CardTypeInfos');
        die;

 以上代码 sql语句输出 :SELECT `CardTypeInfos`.`id`, `CardTypeInfos`.`title` FROM `dkh_yunths`.`card_type_infos` AS `CardTypeInfos` WHERE `seller_id` = 1 AND `del_state` = 1 AND ((`date_info_type` = 2) OR (((`date_info_type` = 1) AND (`begin` >= '1466497533') AND (`end` <= '1466497533'))))

posted @ 2016-06-21 16:32  一个人的孤独自白  阅读(659)  评论(0编辑  收藏  举报