thinkPHP3.2.3怎么获取 总数 今天 昨天 本周 本月 数据量 代码不对 望大神整改
//调查人数:总数;今日;昨日;本周;本月$userOb=D("user_information");$uAll=$userOb->count('*');$uToday=...
//调查人数:总数;今日;昨日;本周;本月
$userOb = D("user_information");
$uAll = $userOb->count('*');
$uToday = $userOb->where("to_days(add_time)=to_days(now())")->count();
$uYesterday = $userOb->where('TO_DAYS(NOW())-TO_DAYS(add_time)<=1')->count();
$uWeek = $userOb->where("YEARWEEK(date_format(add_time,'%Y-%m-%d'))=YEARWEEK(now())")->count();
$uMonth = $userOb->where("DATE_FORMAT(add_time, '%Y%m' ) = DATE_FORMAT(CURDATE() ,'%Y%m' )")->count();
$uArr = array(
'uAll'=>$uAll,
'uToday'=>$uToday,
'uYesterday'=>$uYesterday,
'uWeek'=>$uWeek,
'uMonth'=>$uMonth
);
$this->assign('uArr',$uArr); 展开
$userOb = D("user_information");
$uAll = $userOb->count('*');
$uToday = $userOb->where("to_days(add_time)=to_days(now())")->count();
$uYesterday = $userOb->where('TO_DAYS(NOW())-TO_DAYS(add_time)<=1')->count();
$uWeek = $userOb->where("YEARWEEK(date_format(add_time,'%Y-%m-%d'))=YEARWEEK(now())")->count();
$uMonth = $userOb->where("DATE_FORMAT(add_time, '%Y%m' ) = DATE_FORMAT(CURDATE() ,'%Y%m' )")->count();
$uArr = array(
'uAll'=>$uAll,
'uToday'=>$uToday,
'uYesterday'=>$uYesterday,
'uWeek'=>$uWeek,
'uMonth'=>$uMonth
);
$this->assign('uArr',$uArr); 展开
1个回答
展开全部
对前台传来的商品id数组在表中进行查询
//$goods = array(11,10,7);
$where['goods_id']=array("in",$goods);
$where['user_id'] = $_SESSION['uid'];
$res = D("cart")->where($where)->select();
复制代码
得到sql语句如下
"SELECT * FROM `cart` WHERE `goods_id` IN (11,10,7) AND `user_id` = 1
//$goods = array(11,10,7);
$where['goods_id']=array("in",$goods);
$where['user_id'] = $_SESSION['uid'];
$res = D("cart")->where($where)->select();
复制代码
得到sql语句如下
"SELECT * FROM `cart` WHERE `goods_id` IN (11,10,7) AND `user_id` = 1
追问
这样可以获取到值吗 您可以在我代码的基础上做一下改正吗?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询