私人领地

thinkphp 3.2 join

$res2 = M('stat_info a')
->join(C('DB_PREFIX').'stock b ON a.goods_id = b.goods_id')
->field('a.*,b.goods_sn,b.goods_name,b.goods_barcode')
->select();


$res2 = M('stat_info a')
->join(__STOCK__.' b ON a.goods_id = b.goods_id')
->field('a.*,b.goods_sn,b.goods_name,b.goods_barcode')
->select();

$res = M('stat_info a')
->join('__STOCK__ b ON a.goods_id = b.goods_id')
->field('a.*,b.goods_sn,b.goods_name,b.goods_barcode')
->where('a.stat_id='.$id)
->select();

 


两种方法都可以

 

$res = M('stat_info a')
->join('__STOCK__ b ON a.goods_id = b.goods_id')
->join('__DEPOT__ C ON b.depot_id = c.id')
->field('a.*,b.goods_sn,b.goods_name,b.goods_barcode,c.depot_name')
->where('a.stat_id='.$id)
->select();

 

posted @ 2016-09-03 18:35  狂奔的蜗牛Snails  阅读(1582)  评论(0编辑  收藏  举报