0
条件,使我的数据库有两个表名为球员和团队,每个表都有competitionId和teamId场,所以我的目标是获得competitionId一队基地的所有球员和teamId队表。它只返回一个空数组。Laravel加入与在内部不工作
public static function getTeamRoster($competitionId, $teamId) {
return DB::table('teams as team')
->where('team.competitionId', $competitionId)
->where('team.teamId', $teamId)
->join('players as player', function($join){
$join->on('team.competitionId', '=', 'player.competitionId')
->where('player.teamId', 'team.teamId');
})
->get();
}
,因为在你的代码,它说'WHERE player.teamID =“团队。 teamID''我想你想'WHERE player.teamID = 1'。对? – aldrin27
在连接链接' - > on()'而不是尝试使用' - > where()'。 – Ohgodwhy