Rumah >pembangunan bahagian belakang >tutorial php >Thinkphp两张数据表left join怎么让相同字段不被覆盖?
M('User')->join('LEFT JOIN before_conditions on before_conditions.uid=User.id')->where($mapBarCode)->select();
user表和before_conditions表都有id作为主键
现在我要得到user表的id,但查询出来的结果被before_conditions的id覆盖了,该怎么办?
我知道要改字段别名,原生的我知道,但是tp的数据库语法该怎么改
$Model->field('id,nickname as name')->select();
$name = M('User')->join('LEFT JOIN before_conditions on before_conditions.uid=User.id')->where($mapBarCode)->select();
for($i=0;$i
$name[$i]['b_id'] = $name_b['id'];
}
dump($name); 输出结果user表的id几不会被覆盖
$Model->field('id,nickname as name')->select();
$name = M('User')->join('LEFT JOIN before_conditions on before_conditions.uid=User.id')->where($mapBarCode)->select();
for($i=0;$i
$name[$i]['b_id'] = $name_b['id'];
}
dump($name); 输出结果user表的id几不会被覆盖