Php 列';id';在字段列表中使用雄辩的
有人知道为什么下面会导致字段列表中的列“id”不明确错误吗Php 列';id';在字段列表中使用雄辩的,php,sql,laravel,eloquent,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_subj
$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');
我指定了要引用ID的表,因此无法理解为什么会出现此错误。使用
select()
而不是lists()
。希望它能起作用。我发现以下方法可以解决问题:
$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');
这导致Htmlenties()期望参数1为字符串,对象给定错误我出于好奇尝试了它,但仍然导致Htmlenties()期望参数1为字符串,对象给定错误。不过我有一个可行的解决方案(见我的答案)。