vendredi 16 avril 2021

Laravel application error 500 from SQLSTATE[42S22]: Column not found: 1054 Unknown column

how are you? I have a laravel application in xampp with php 7, when I want to login I get an error 500, if I check the error_log in the storage folder, I see that it is the following error:

[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) [stacktrace]

This is my first time whit laravel, I don't know how to resolve this issue, the code of the lines 326 and 664 are the next:

326) 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();
    });
}
  1. Is only the catch of teh error, maybe could be usefull

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
        );
    }

I received this application from a company that has me as an intern, but they didn't give me any more help or guidance, they just want it to work. I appreciate any comments that can help me solve it.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2QuC5ge
via IFTTT

Aucun commentaire:

Enregistrer un commentaire