第31次PHP作业--订单列表

<?php

namespace Home\Controller;
use Think\Controller;
class UserController extends Controller{
      public function _initialize() {
        //判断是否登录
        if (empty($_SESSION['uid'])) {
            $this->error('请先登录', U('Index/login'));
        }
    }
    public function index(){
        $uid=$_SESSION['uid'];
        
        $where = array(
            'uid' => $_SESSION['uid']
        );
        //统计表记录数
        $num=M('order')->where('uid='.$uid)->count();
        $page = new \Think\Page($num, 1);


      
            $list=M('order')->where('uid='.$uid)->order('id desc')->limit($page->firstRow . ',' . $page->listRows)->select();
      
           
            foreach ($list as $key=> $val){
           $list[$key]['sub'] = M('orderProduct')->where('oid=' . $val['id'])->select();
            
          $list[$key]['subcount'] =  count($list[$key]['sub']);//统计产品数,用户于合并列
            }
       
             $this->list=$list;
           $this->page= $page->show();
   
        $this->display();
    }
    public function quit(){
        $id=I('get.id');
        M()->query('delete a,b,c from mp_order as a left join mp_order_product as b on a.id=b.oid left join mp_order_log as c on a.id=c.oid where a.id='.$id.'');
        $this->redirect('User/index');
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值