0
我有2个表Orders
和Products
。在orders
表中有外键product_id
。有时,订单不一定包含产品(没有任何产品ID的订单是允许的)。在这种情况下,我存在导致问题保存数据的验证规则。cakePHP验证existsIn()为空/空字段,如何摆脱...?
$rules->add($rules->existsIn(['product_id'], 'Products')); //Validation in the model of Orders.
N.B. - 请记住,我已允许product_id在我的数据库中为空。
通常修改,承认'null'应开箱的(因为在DB列可以为空)。 ** HTTPS://github.com/cakephp/cakephp/blob/3.4.12/src/ORM/Rule/ExistsIn.php#L113** – ndm