Hi Andruu,

I had a problem like that once ans solved it by saving the 0 as String '0'. 
Weird, but it worked. I guess the 0 was interpretetd as boolean false.

Anja

-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im Auftrag 
von andruu
Gesendet: Freitag, 12. Dezember 2008 08:29
An: CakePHP
Betreff: Zero values being submitted as NULL into DB.


Hello, I have a simple form to edit my category model. My category model is 
using the Tree behavior. When trying to edit/update my model's parent_id if the 
value is 0 it is being submitted as NULL into the database. The database type 
is integer.

I am looking for a solution to preserve the initial value of 0 (zero).

If I do a pr($this->data) it shows the correct values but when I look in the 
SQL log I can see that NULL is being submitted.

 Array
(
    [Category] => Array
        (
            [parent_id] => 0
            [name] => Apparel
            [description] =>
        )

)

SQL LOG
UPDATE `categories` SET `parent_id` = NULL, `name` = 'Apparel', `description` = 
'', `modified` = '2008-12-12 14:27:13' WHERE `categories`.`id` = 7

Also it works fine if the value is not 0.

Thanks in advance for any help.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to