您的位置:首页 > 编程语言 > PHP开发

cakephp 复杂查询

2016-06-21 16:32 501 查看
$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'))))
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: