我正在开发应用程序的后端,并且我使用laravel 在恢复中,我想选择该用户的安全问题
$User_data = User::where('email', '=', $email)->leftJoin('secutitequestion', function($join) {
$join->on('users.id', '=', 'secutitequestion.user_id')->pluck('secutitequestion.securite_question1'
,'secutitequestion.answer_securite_question1'
,'secutitequestion.securite_question2'
,'secutitequestion.answer_securite_question2'
,'secutitequestion.securite_question3'
,'secutitequestion.answer_securite_question3');
});
这就是我得到的:
“ SQLSTATE [42000]:语法错误或访问冲突:1064 您的SQL语法错误;检查与您的手册相对应的手册 在
users
上的''附近使用正确语法的MySQL服务器版本。id
=secutitequestion
。user_id
”位于第1行(SQL:选择secutitequestion
。securite_question1
, {{1}上的secutitequestion
。answer_securite_question1
。users
=id
。secutitequestion
)”
答案 0 :(得分:0)
您正在->pluck
内部呼叫leftJoin
,但应该在外部呼叫。请在下面尝试我的代码
$User_data = User::where('email', '=', $email)
->leftJoin('secutitequestion', function($join) {
$join->on('users.id', '=', 'secutitequestion.user_id');
})
->select('secutitequestion.securite_question1'
,'secutitequestion.answer_securite_question1'
,'secutitequestion.securite_question2'
,'secutitequestion.answer_securite_question2'
,'secutitequestion.securite_question3'
,'secutitequestion.answer_securite_question3')
->get();