使用 Eloquent 时字段列表中的列“id”不明确

Cla*_*ire 3 php sql laravel eloquent

有谁知道为什么以下会导致字段列表中的列“id”是不明确的错误?

$app_subj_current = \DB::table('tbl_subject')
        ->join('tbl_application', 'tbl_subject.id', '=', 'tbl_application.app_subj_id')
        ->where('tbl_application.id', $application)
        ->lists('tbl_subject.subj_type', 'tbl_subject.id');
Run Code Online (Sandbox Code Playgroud)

我已经指定了我所指的 ID 的表,所以我不明白为什么我会收到这个错误。

Cla*_*ire 6

我发现以下解决了这个问题:

$app_subj_current = \DB::table('tbl_subject')
    ->join('tbl_application', 'tbl_subject.id', '=', 'tbl_application.app_subj_id')
    ->where('tbl_application.id', $application)
    ->select('tbl_subject.subj_type as x', 'tbl_subject.id as y')
    ->lists('x', 'y');
Run Code Online (Sandbox Code Playgroud)