Prestashop and null fields in DB

非 Y 不嫁゛ 提交于 2019-12-10 23:41:30

问题


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:


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.



来源:https://stackoverflow.com/questions/19987401/prestashop-and-null-fields-in-db

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!