SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value ERROR IN MYSQL

 * @throws \Illuminate\Database\QueryException

 */

protected function runQueryCallback($query, $bindings, Closure $callback)

{

    // To execute the statement, we'll simply call the callback, which will actually

    // run the SQL against the PDO connection. Then we can calculate the time it

    // took to execute and log the query SQL, bindings and time in our memory.

    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

        );

    }



    return $result;

}



/**

 * Log a query in the connection's query log.

 *

 * @param  string  $query

 * @param  array  $bindings

 * @param  float|null  $time

 * @return void

 */

Hello @anon31249651, please fill out the template when creating a new topic.
What is your URL?
What is the error message?
What is supposed to happen?
Thanks.

Is the id field marked as AUTO_INCREMENT? Or should your code provide it?

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.