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:
I'm using a model and entities. Help?
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 => '', 1 => 'Yes', 0 => '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 ugly, theres gotta be a "cleaner" way?
You can see things I made with codeigniter here: itart.pro its not overly impressive as I have very little time to learn.