tp3.2 模型sum between join where order select方法使用
阿新 • • 發佈:2019-01-30
$start_time = strtotime(date("Y-m-d 00:00:00"),time()); $end_time = strtotime(date("Y-m-d 23:59:59"),time()); $map_ok['cy_pay_ok.create_time'] = array('between',array($start_time,$end_time),'AND'); $map_ok['cy_game.cps_recommend'] = array('neq',0); $map_ok['cy_pay_ok.regagent'] = array('in',$user_agents); $todayAmount = M('pay_ok','cy_') ->join('LEFT JOIN cy_game ON cy_pay_ok.gameid = cy_game.id') ->where($map_ok)->sum('cy_pay_ok.agent_amount'); $todayAmount = empty($todayAmount)?'0.00':$todayAmount; //4. 財務最近變化記錄 一週內 $start = strtotime('-7 days',strtotime(date('Y-m-d 00:00:00',time()))); $end = time(); $map['created_at'] = ['between',[$start,$end]]; $map['is_deleted'] = 0; $recently= M('cps_wallet_record','cy_')->where($map)->order('id desc')->select();