A-A+
ThinkPHP:join()方法,字段冲突问题
今天遇到一个问题,join方法多表查询,其中2表有相同的字段发生冲突。
解决办法,冲突的查询的字段和冲突的条件字段前加上要查询的表名,就可以解决冲突问题!
$data = $mdl->join('cg_goods ON cg_goods.goods_id = cg_order_detail.goods_id','left')->field('cg_order_detail.goods_id,title,orderno,num,price1,price2,cg_order_detail.special_offers,package')->where(array('cg_order_detail.goods_id'=>$val['goods_id']))->find();