码迷,mamicode.com
首页 > Web开发 > 详细

cakephp 复杂查询

时间:2016-06-21 17:20:17      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:

        $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‘))))

cakephp 复杂查询

标签:

原文地址:http://www.cnblogs.com/-mrl/p/5604105.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!