Null values for numeric values/ mysql

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Null values for numeric values/ mysql

mauijaws

It seems that various people have problems when saving null values. In
particular when it comes to numeric values it should be possible to
store null values. This might be a mysql related problem as cake
renders an empty input as '' (when a db record gets updated)

After I checked the source, I modified the value function in the
DboMysql class, so that it returns the string null when column type is
integer or float. Are there plans to incoporate a similar change in
cake in the future? The phpdoc comment suggests that the safe param in
the function (currently unused) might fullfill this purpose in the
future.

Does anybody have a better solution?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Null values for numeric values/ mysql

Shalanga

I don't understand your problem, because if a set $myVariable = null;
in the MySql it is store (NULL) in numeric or whatever variable type it
is.

Of course in mysql *not null* should not me set.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Null values for numeric values/ mysql

ianmac-2



On Nov 2, 8:58 pm, "Ismael S. Kafeltz" <[hidden email]> wrote:
> I don't understand your problem, because if a set $myVariable = null;
> in the MySql it is store (NULL) in numeric or whatever variable type it
> is.
>
> Of course in mysql *not null* should not me set.

Also - if your INT column is part of the primary key then mysql will
not allow it to be NULL


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Null values for numeric values/ mysql

mauijaws
In reply to this post by Shalanga

Lets say I have a form to modify my data model. The data model contains
numeric values. In my view I use input fields to manage numeric values.
 When the controller creates the data row everything is fine as empty
inputs are not handled in the mysql insert statement issued by cake.
However when you want to modify an existing data row ,the mysql update
statement from cake will contain your empty inputs. In the case of
numeric values cake will render an empty input with '' in the update
statement. This will be interpreted as "0" (at least in mysql 4.1),
even if you define the default value as NULL in mysql.
Of course I could manually set my data model values to null before I
update it, but that does not seem right.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---