Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too many Field 'xxx' doesn't have a default value #49

Open
upliu opened this issue Jul 7, 2017 · 2 comments
Open

Too many Field 'xxx' doesn't have a default value #49

upliu opened this issue Jul 7, 2017 · 2 comments

Comments

@upliu
Copy link

upliu commented Jul 7, 2017

I use mysql version 5.7.18.
when i run ./yii cms/install , these two error occurd:

  • created_at out of range , because created_at is int in db table column, new Expression('NOW()') isn't a valid value
  • intro_content deesn't have a defautl value

after i fix errors above.

I try to add a menu in admin, i got an exception, Field 'route' doesn't have a default value.

@upliu
Copy link
Author

upliu commented Jul 7, 2017

The default SQL mode in MySQL 5.7 includes these modes: ONLY_FULL_GROUP_BY, STRICT_TRANS_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, and NO_ENGINE_SUBSTITUTION.

https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_strict_trans_tables

disable STRICT_TRANS_TABLES option may be help

@upliu
Copy link
Author

upliu commented Jul 7, 2017

Add 3 line of code in common/config/db.php could resolve this problem

'on afterOpen' => function($event){
    $event->sender->pdo->exec('set sql_mode=""');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant