所以我尝试使用 Laravel 5.5 制作一个基于帐户的网站。
我有一个数据库表“users”,其中包含:
id - int(10)[PRIMARY_KEY],
created_at - 时间戳,
updated_at - 时间戳,
用户名 - varchar [FOREIGN_KEY]
密码 - varchar
我的数据库中已有用户名和密码
用户名:vanderozili
密码:jaujaujau
当我尝试使用此验证登录时
$validation = Validator::make( $request->all(), [
'username' => 'username|required',
'password' => 'required|min:8'
]);
if(Auth::attempt(['username', $request->input('username'), 'password', $request->input('password')])){
return redirect('/shop');
}
return redirect()->back();
}
我遇到了这个错误。
(2/2) QueryException
SQLSTATE[42S22]:未找到列:1054“where 子句”中存在未知列“0”(SQL:从 users
中选择 *,其中 0
= 用户名和 1
= vanderozili 和 2
= 密码和 3
= jaujaujau 限制 1)
我通过 phpmyadmin 使用 mysql
我已经在网上搜索过,但没有看到与我遇到的类似问题。问题出在哪里?
最佳答案
此参数应该是列名称/值对的关联数组,而不是简单的数组值系列:
if(Auth::attempt(['username' => $request->input('username'), 'password' => $request->input('password')])){`
如Laravel Docs所示
关于php - SQLSTATE[42S22] : Column not found: 1054 Unknown column '0' in 'where clause' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46775468/