一般情况下,我们在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 终于正确查询···但是为什么非得要我写成两个元素的数组呢······差评!!差评!!
网友评论