When I want to save a record with some fields set to empty strings
cake strips them out (from DboSource::create):
>> if ($set === "''") {
>> unset ($fieldInsert[$i]);
>> } else {
>> $valueInsert[] = $set;
>>}
And since I use MySQL 5 and the fields that I'm trying to save empty
strings to are NOT NULL I get an error from MySQL (from mysql docs):
As of MySQL 5.0.2, if a column definition includes no explicit DEFAULT
value, MySQL determines the default value as follows:
If the column can take NULL as a value, the column is defined with an
explicit DEFAULT NULL clause. This is the same as before 5.0.2.
If the column cannot take NULL as the value, MySQL defines the column
with no explicit DEFAULT clause. For data entry, if an INSERT or
REPLACE statement includes no value for the column, MySQL handles the
column according to the SQL mode in effect at the time:
* If strict SQL mode is not enabled, MySQL sets the column to the
implicit default value for the column data type.
* If strict mode is enabled, an error occurs for transactional
tables and the statement is rolled back. For non-transactional tables,
an error occurs, but if this happens for the second or subsequent row
of a multiple-row statement, the preceding rows will have been
inserted.
Text/blob fields can't have a default value, so I don't see a way for
me to solve this other than to alter cake DboSource::create code, but
I'm really interested why does DboSource::create strips empty strings,
what is the reason for this and what is the best solution here?
Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---