Re: Why cake save to 0 value if you are editing a model ?
When you submit a form, your data will contain empty values and when cake tries to insert these empty values into your columns which allow NULL, it will be 0 or -00-00 for dates. See: http://bakery.cakephp.org/articles/view/null-behavior#958 Slight updated to use $this-loadInfo() instead: http://bin.cakephp.org/view/580118960 On 5/23/07, ricarou51 [EMAIL PROTECTED] wrote: So cake considers 0 as default value for an integer isn't it ? On 23 mai, 15:44, Davide [EMAIL PROTECTED] wrote: Chris Hartjes wrote: Perhaps I'm wrong, but last I checked you can't set an integer to NULL...the default for an integer would be zero, wouldn't it? on MySQL 4.1.14-nt (Windows XP) CREATE TABLE `xyz` ( `field1` int(11) default NULL, `field2` int(11) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 mysql insert into xyz (field2) value (1); Query OK, 1 row affected (0.00 sec) mysql select * from xyz; +++ | field1 | field2 | +++ | NULL | 1 | +++ 1 row in set (0.00 sec) I had the doubt too :) Bye Davide --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Why cake save to 0 value if you are editing a model ?
Hello, I've this problem : for any table which contains 'int' fields ( I put default value at NULL in the database) , when I add a row whitout filling the input for my int field, there is no problem but when I edit a row , if the input for int field is empty, cake saves it to 0 and not to NULL Thanks for yours answers --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Why cake save to 0 value if you are editing a model ?
On 5/23/07, ricarou51 [EMAIL PROTECTED] wrote: Hello, I've this problem : for any table which contains 'int' fields ( I put default value at NULL in the database) , when I add a row whitout filling the input for my int field, there is no problem but when I edit a row , if the input for int field is empty, cake saves it to 0 and not to NULL Thanks for yours answers Perhaps I'm wrong, but last I checked you can't set an integer to NULL...the default for an integer would be zero, wouldn't it? -- Chris Hartjes My motto for 2007: Just build it, damnit! @TheBallpark - http://www.littlehart.net/attheballpark @TheKeyboard - http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Why cake save to 0 value if you are editing a model ?
Chris Hartjes wrote: Perhaps I'm wrong, but last I checked you can't set an integer to NULL...the default for an integer would be zero, wouldn't it? on MySQL 4.1.14-nt (Windows XP) CREATE TABLE `xyz` ( `field1` int(11) default NULL, `field2` int(11) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 mysql insert into xyz (field2) value (1); Query OK, 1 row affected (0.00 sec) mysql select * from xyz; +++ | field1 | field2 | +++ | NULL | 1 | +++ 1 row in set (0.00 sec) I had the doubt too :) Bye Davide --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Why cake save to 0 value if you are editing a model ?
So cake considers 0 as default value for an integer isn't it ? On 23 mai, 15:44, Davide [EMAIL PROTECTED] wrote: Chris Hartjes wrote: Perhaps I'm wrong, but last I checked you can't set an integer to NULL...the default for an integer would be zero, wouldn't it? on MySQL 4.1.14-nt (Windows XP) CREATE TABLE `xyz` ( `field1` int(11) default NULL, `field2` int(11) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 mysql insert into xyz (field2) value (1); Query OK, 1 row affected (0.00 sec) mysql select * from xyz; +++ | field1 | field2 | +++ | NULL | 1 | +++ 1 row in set (0.00 sec) I had the doubt too :) Bye Davide --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---