TP5.0 的 not null 查询

一般情况下,我们在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

 

posted @ 2020-06-12 14:20  景北斗  阅读(1870)  评论(0编辑  收藏  举报