Prestashop and null fields in DB

2019-07-20 16:22发布

I have a very simple piece of code :

$dropOrder = new DropOrder($dropOrderId);
$dropOrder->is_supplier_paid = $payValue;
$dropOrder->save();

It works and saves a 'is_supplier_paid' field value into the database. But it also does unexpected actions and fills all null valued fields with 0 values.

I try to save it like this :

$dropOrder->save(true);

But I still have the same strange behavior. I want to change one field only and don't touch the other ones.

1条回答
SAY GOODBYE
2楼-- · 2019-07-20 16:58

Values are formated by ObjectModel::formatValue() before they are inserted / updated, based on the type of the field declared in your $definition.

You have to use TYPE_NOTHING to allow NULL values, it's the only way.

Take a look in Configuration class, with id_shop and id_group_shop fields.

查看更多
登录 后发表回答