<?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');
}
}
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');
}
}