0

I was doing some self learning on CakePHP 1.26 with Mysql 5.
I got a simple table with only one field and had applied "Not Null" to this field.
This field in the table was corresponding to a Input text box in a HTML form.
I tried not to enter anything into the Input text field, and then
I saw that empty data was able to be stored into the Table even if "Not Null" had been applied to this field.

I am confused of this result. Could you help me please?

4

2 回答 2

2

您可能正在存储一个空字符串。空字符串 ('') 与 null 不同。

于 2010-06-11T15:39:21.453 回答
2

“空”和“空白”是有区别的。如果你尝试SELECT * FROM your-table WHERE your-not-null-column IS NULL,你会得到任何回报吗?如果你尝试SELECT * FROM your-table WHERE your-not-null-column = '',你会得到什么?

于 2010-06-11T15:41:35.287 回答