Expect:
select robotid, number from tool where is_active = 1
select * from robot_team where id = robotid( robotid from tool)
foreach id(from robot_team), number(from tool) , status_za(from robot_team), status_zb(from robot_team), status_zm(from robot_team), status_qs(from robot_team)
Result:
- cannot show success through postman
Code:
public function robotStatus()
{
$arr=[];
$robotlist = DB::table('robot_team AS u')
->Join(DB::connection('sql')->table('tool AS m'), 'u.id', '=', 'm.robotid')
->select('u.*', 'u.id AS uid', 'm.number AS mnumber')
->where('m.is_active', '=', 1)
->orderBy('u.id', 'desc')
->get();
if(count($robotlist)>0){
foreach ($robotlist as $v) {
$robot_arr = [
"id" => $v->uid,
"number" => $v->mnumber,
"FA" => $v->status_fa,
"FC" => $v->status_fc,
"FM" => $v->status_fm,
"PS" => $v->status_ps
];
$arr[]=$robot_arr;
}}
return $arr;
}
Comment:
Hello all,
Laravel : join two tables of different db connections
I try to combine using the above code but it is fail.
I have read the above link but it cannot reach my purpose as two table in different db in mysql.
Please help me to solve the above problems.
Thank you all.