Setting a NULL-able field to '0'/false is treated as setting them to NULL, because of the empty() test used in set().
This makes it impossible to set the value to '0'/false, or read those values from a database. Do note that Postgres, for example, does have 'real' booleans and that my Postgres driver does allow me to set columns to FALSE (and not 1/0 as being done in MySQL).
I can suggest two possible solutions:
When a field is NULLable, only 'real' php's null would be treated as null, and nothing else. FALSE, zero and empty strings will be reserved and not converted to NULL. In some cases, an empty string could mean something different than NULL.
Replacing the empty() check with a more strict one that doesn't consider FALSE, '0' (as string) and 0 (as integer) as NULL. This will still make empty strings, empty arrays and declared variables with no value consider NULL.
Setting a NULL-able field to '0'/false is treated as setting them to NULL, because of the
empty()
test used inset()
.This makes it impossible to set the value to '0'/false, or read those values from a database. Do note that Postgres, for example, does have 'real' booleans and that my Postgres driver does allow me to set columns to FALSE (and not 1/0 as being done in MySQL).
I can suggest two possible solutions:
empty()
check with a more strict one that doesn't consider FALSE, '0' (as string) and 0 (as integer) as NULL. This will still make empty strings, empty arrays and declared variables with no value consider NULL.