views:

24

answers:

2

Hi all,

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?

+2  A: 

You're probably storing an empty string. An empty string ('') is not the same as a null.

Paul Tomblin
+2  A: 

There's a difference between "null" and "blank". If you try SELECT * FROM your-table WHERE your-not-null-column IS NULL, do you get anything back? If you try SELECT * FROM your-table WHERE your-not-null-column = '', what do you get?

TMN