Cakephp find null

问题描述 投票:0回答:1

我想让所有人都有一个空字段。

我尝试了以下操作,但未返回任何内容。

$plato = $this->Platos->find('all',[
            'conditions' => ['alergia_id' => null]
        ]);
list cakephp find
1个回答
0
投票

在SQL中,null不等于(=)-甚至不等于另一个null。根据SQL的三值逻辑,结果null = null不是正确的,但未知。 SQL具有is [not] null谓词测试特定值是否为null。

https://modern-sql.com/feature/is-distinct-from

这是解决方案。

$plato = $this->Platos->find('all',[
            'conditions' => ['alergia_id IS null']
        ]);
© www.soinside.com 2019 - 2024. All rights reserved.