MySQL Inserts record with NULL value in NOT NULL column

后端 未结 3 1770
孤城傲影
孤城傲影 2020-12-09 19:38

Why does the first INSERT go through for table2. Note that table2.col_1 is NOT NULL. It doesn\'t insert NULL for col_1, but mysteriously converts the NULL value to an empty

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 20:11

    You have MySQL's STRICT mode OFF. Turn it on and you'll get an error.

    Otherwise you can test for those warnings with PDO via: http://php.net/manual/en/pdo.errorinfo.php

提交回复
热议问题