Welcome Guest, Not a member yet? Register   Sign In
NULL into MYSQL db with active record???
#1

[eluser]nevsie[/eluser]
Its late, and i am probably missing something obvious...
but i have two fields of "hours" (int) and "price" (float) and i am using active record methods to insert the data into the database... the fields are allowed to be null, and setting it to (NULL) through a desktop SQL editor correctly stores the null value in the database...

However, when ever i send values of "" or "null" or "(NULL)" or just not send any value at all the fields set to "0" and "0.00"... not as null...

Any ideas or help on this one...?
Just thought about default values of null - but this does not get accepted... anything other ideas?
#2

[eluser]JHackamack[/eluser]
I believe "" or "null" or "(NULL") in php are considered strings. I usually insert them like this
$update['value'] = NULL;

That usually sets the value to null.
#3

[eluser]nevsie[/eluser]
yup, your bang on... i knew it would be a tired obvious mistake! one too many drinks last night, and way too little sleep too! i had run through so many options, and i could not see the wood for the trees! why i was throwing everything in quotes as strings is beyond me! but easy resolved - thanks again.




Theme © iAndrew 2016 - Forum software by © MyBB