Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Error 1364, field 'last_login' doesn't have a default value
  • Hello,
    I'm following Phil Sturgeon's tutorial on NetTuts+ about simpleauth. http://tutsplus.com/lesson/authentication/.
    I've logged into the console using :
    php oil console
    

    When I do
    Auth::create_user( 'bob', 'pass', 'bob@mail.com', 100);
    
    I receive the following error message:
    Error - SQLSTATE[HY000]: General error: 1364 Field 'last_login' doesn't have a d
    efault value with query: "INSERT INTO `users` (`username`, `password`, `email`,
    `group`, `profile_fields`, `created_at`) VALUES ('philsturgeon', 'NtgTF8q6Z9UyyU
    wQS7Ma5Bvj+uTrK/F66iMji9su1XY=', 'phil@example.com', 100, 'a:0:{}', 1341765140)"
    in COREPATH/classes/database/pdo/connection.php on line 167
    I've looked at the docs for simpleauth and it's written that create_user should be used with the parameters that have been given. The 'users' table has been created using the code in the docs. Does anyone know why this problem is happening? Is the fact that I'm using windows creating the problem? Thanks
  • The problem here is your table definition. You have defined the 'last_login' column as "NOT NULL", but didn't specify a default value. Obviously, when you create a new user there is no last_login timestamp, so it's not present in the INSERT query. So either allow it to be NULL, or give it a default value (of zero for example).
  • Thanks Harro, I ended up giving it a default value of 0 in the end. I just thought that the table creation script in the docs (http://docs.fuelphp.com/packages/auth/simpleauth/intro.html) would allow simpleauth to work straight away. Anyway, thanks for the answer
  • I've corrected the SQL in the 1.3 docs.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion