Php SQLSTATE[42S22]中的Laravel应用程序错误500:未找到列:1054未知列
我在xampp和php 7中有一个laravel应用程序,当我想要登录时,我得到一个错误500,如果我检查存储文件夹中的错误日志,我看到它是以下错误:Php SQLSTATE[42S22]中的Laravel应用程序错误500:未找到列:1054未知列,php,mysql,laravel-5,xampp,Php,Mysql,Laravel 5,Xampp,我在xampp和php 7中有一个laravel应用程序,当我想要登录时,我得到一个错误500,如果我检查存储文件夹中的错误日志,我看到它是以下错误: [2021-04-16 23:36:32] live.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'username' in 'where clause' (SQL: select * from `users` where `username` = admin and
[2021-04-16 23:36:32] live.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'username' in 'where clause' (SQL: select * from `users` where `username` = admin and `users`.`deleted_at` is null limit 1)
{"exception":"[object] (Illuminate\\Database\\QueryException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'username' in 'where clause' (SQL: select * from `users` where `username` = admin and `users`.`deleted_at` is null limit 1) at
C:\\xampp\\htdocs\\p2\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php:664, PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'username' in 'where clause' at C:\\xampp\\htdocs\\p2\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php:326)
这是我第一次见到whit laravel,我不知道如何解决这个问题,第326行和第664行的代码是下一个:
326
我很感激任何能帮助我解决这个问题的评论。这意味着
用户名
不是用户
表中的一列。你把这个错误理解成不同的意思了吗?我只想知道为什么?如果phpmyadmin中的数据库没有给我任何错误。证明它,将show create table users
编辑到您的问题中。
public function select($query, $bindings = [], $useReadPdo = true)
{
return $this->run($query, $bindings, function ($query, $bindings) use ($useReadPdo) {
if ($this->pretending()) {
return [];
}
// For select statements, we'll simply execute the query and return an array
// of the database result set. Each element in the array will be a single
// row from the database table, and will either be an array or objects.
$statement = $this->prepared($this->getPdoForSelect($useReadPdo)
->prepare($query));
$this->bindValues($statement, $this->prepareBindings($bindings));
$statement->execute();
return $statement->fetchAll();
});
}
protected function runQueryCallback($query, $bindings, Closure $callback)
{
try {
$result = $callback($query, $bindings);
}
// If an exception occurs when attempting to run a query, we'll format the error
// message to include the bindings with SQL, which will make this exception a
// lot more helpful to the developer instead of just the database's errors.
catch (Exception $e) {
throw new QueryException(
$query, $this->prepareBindings($bindings), $e
);
}