tp3.2 模型sum between join where order select方法使用

$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();

猜你喜欢

转载自blog.csdn.net/mengzuchao/article/details/80708796
今日推荐