tp3.2中三表联查(join和 left join)
来源:互联网 发布:软件设计师资格证书 编辑:程序博客网 时间:2024/06/06 02:27
一;join:
$orders = M('orders');
$field = 'o.id, o.money, o.pay_type, o.status, o.score_before, o.score_after, o.ctime, u.realname AS username, s.platform AS sellername, c.realname AS companyname';
//$totalRows = $orders->alias('o')->where('o.status > 0 ' . $where)->count('o.id');
$totalRows = $orders->alias('o')->where($where)->count('o.id');
$page = new \Think\Page($totalRows, $this->limit);
$maxPages = ceil($totalRows/$this->limit);
$curr = ($curr > $maxPages) ? $maxPages : $curr;
$ordersList = $orders
->alias('o')
->field($field)
->join('zbt_user AS u ON o.user_id = u.id')
->join('zbt_seller AS s ON o.seller_id = s.id')
->join('zbt_company AS c ON o.company_id = c.id')
//->where('o.status > 0 ' . $where)
->where($where)
->page($curr, $this->limit)
->select();
二: left join
$order_goods_data= M("order_goods")
->alias('g')
->field('g.*,o.ordercode AS code,o.ctime,o.pay_type AS type,d.unitname AS unit,d.title AS goodsname')
->join('left join zbt_orders AS o ON g.orderid=o.id')
->join('left join zbt_goods AS d ON g.goodsid=d.id')
->where(array("g.storeid"=>$id))
->select();
//var_dump($order_goods_data);die;
$this->assign('order_goods_data',$order_goods_data);
- tp3.2中三表联查(join和 left join)
- INNER JOIN和left JOIN
- inner join和left join
- left join 和 right join
- inner join 和 left join
- INNER JOIN 、 LEFT JOIN 和 RIGHT JOIN
- inner join、Left Join和Right join
- left join 和 left outer join
- 关于left join 和 left outer join
- left join 和 left outer join
- left join 和left outer join
- TP3.2 Join和where一起使用的问题
- Left join --案例2
- left join和right join的区别
- LEFT JOIN 和 RIGHT JOIN 运算
- Left Join和Inner Join的体会
- SQL 中 Left Join 和Right Join
- iner join和left join的区别
- 信号的稀疏表示
- mysql 1055
- 服务器配置
- Matlab图形绘制经典案例 (2)
- <NOIP> 20 . P1598 垂直柱状图
- tp3.2中三表联查(join和 left join)
- 只包含因子2 3 5的数 51nod1010
- 堆的判断(1098)
- nio3
- netty之Future和ChannelFuture
- C++下的Date类编写
- 58. Length of Last Word
- 10. 电池曲线
- iOS 手势