yii2 - MySQL [23000] Column cannot be null
PHP中文网
PHP中文网 2017-04-17 14:57:55
0
4
754

MySQL 表结构字段 face char(20) NOT NULL 。
插入数据的时候,当face值设置为NULL,报错 MySQL SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'face' cannot be null

MariaDB [db2_dalu]> select version();
+--------------------+
| version()          |
+--------------------+
| 5.5.41-MariaDB-log |
+--------------------+
1 row in set (0.00 sec)

但是我本地却没有这样的情况,本地的MySQL版本:

mysql> select version();
+------------+
| version()  |
+------------+
| 5.6.17-log |
+------------+
1 row in set (0.00 sec)

mysql>
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(4)
大家讲道理

What’s the point of posting this? It’s obviously a problem during insertion. You should post the inserted code.
And I think there is nothing wrong with the prompt, because you require that it cannot be empty. When you insert a null value, it would be strange not to remind you.

洪涛

Obviously not null is set, so null values ​​cannot be inserted. You said before that the local version can be inserted. This must be a supernatural phenomenon.

伊谢尔伦

Is it because the higher version has stricter restrictions?

迷茫

This. . Whether in MySQL's strict mode or non-strict mode, you can set whether to remind you of null values.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!