一般情況下,我們在tp5中需要查詢 not null 的字段直接使用
where('view', 'not null')
就可以正確的查詢
但如果我們有多個字段呢?
$where = [ 'field1' => 'xx', 'view' => 'not null' ]; // 字符串意義的 not null 也就是你查詢到的是 === not null 這段字符串的數據 $where = [ 'field1' => 'xx', 'view' => ['eq', 'not null'] ]; // 和上面一個方式一樣字符串意義的 not null $where = [ 'field1' => 'xx', 'view' => ['not null'] ]; // 這樣會報錯,因為tp5 一定回去找 第二個元素,也就是下標為1的元素 $where = [ 'field1' => 'xx', 'view' => ['not null', ''] ]; // emmmm 終於正確查詢···但是為什么非得要我寫成兩個元素的數組呢······差評!!差評!!
https://www.jianshu.com/p/a0d67560a9f8
PreacherPDieE