Any column not explicitly given a value is set to its default value. For example, if you specify a column list that doesn't name all the columns in the table, unnamed columns are set to their default values. [...] Our view is that checking of fields content should be done in the application and not in the database server.
[mysql.com...]
am wondering if the subbmission form is actually taking the value from the images field and adding it irrespective of whether there is anything there, so in effect putting a null value in?
Yes, thatīs exactly what you are doing. Only if you do not mention the column in your INSERT statement at all or if you are using the DEFAULT value will the db server use the default value.
As jatar_k pointed out in his last post and as mentioned in the above quote from the MySQL documentation you might want to check the value at the application level.
Andreas
Yes, thatīs exactly what you are doing. Only if you do not mention the column in your INSERT statement at all or if you are using the DEFAULT value will the db server use the default value.
as i remember, you can even set it to NULL (not '') and mysql will then fix it to DEFAULT on the fly. even if it's not quite a good sql style.
nevertheless, why not perform a simple check if it's empty (=='') and then setting it to your default. this will save space in the db and you haven't got the default na.gif encoded in your db as default, but in your app. i think this is smoother.
as i remember, you can even set it to NULL (not '') and mysql will then fix it to DEFAULT on the fly.
No hakre, MySQL will not do that. As explained in that quote from mysql.com the default value will be used only when the column name is not explicitly set or the DEFAULT keyword, which is available in versions 4+, is used.
You might confuse that with the fact that you may use NULL for a auto_increment column to increase the value by one.
Andreas