Welcome Guest, Not a member yet? Register   Sign In
Insert NULL
#1

(This post was last modified: 05-06-2020, 12:50 PM by Leo.)

Hello! I can't update my product with a NULL value in one of the table cells in MariaDb

So I have a column which I want to be either 1, 0, or NULL
It is a tinyint(1), default null, column

I'm trying to update the data like this:
PHP Code:
//in my form, in view
form_dropdown('valid', [null => ''=> 'Yes'=> 'No'])

//in my controller
$product->fill($_POST);
$model->save($product);


right now I made a quick fix to make it work like this:
$product->fill($_POST);
$product->project_variant = ($_POST['valid'] === '1' || $_POST['valid'] === '0') ? $_POST['valid'] : null
$model
->save($product);

But this is so long and uglytheres gotta be a "cleaner" way
I'm using a model and entities. Help?
You can see things I made with codeigniter here: itart.pro its not overly impressive as I have very little time to learn.
Reply


Messages In This Thread
Insert NULL - by Leo - 05-06-2020, 12:34 PM
RE: Insert NULL - by jreklund - 05-06-2020, 01:01 PM
RE: Insert NULL - by Leo - 05-07-2020, 01:12 AM
RE: Insert NULL - by jreklund - 05-07-2020, 11:23 AM
RE: Insert NULL - by Gary - 05-07-2020, 05:40 PM
RE: Insert NULL - by Leo - 05-08-2020, 10:07 PM
RE: Insert NULL - by Gary - 05-09-2020, 09:13 AM
RE: Insert NULL - by Leo - 05-09-2020, 03:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB