美文网首页
TP5.0 的 not null 查询

TP5.0 的 not null 查询

作者: PreacherPDieE | 来源:发表于2018-10-27 10:34 被阅读0次

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

相关文章

网友评论

      本文标题:TP5.0 的 not null 查询

      本文链接:https://www.haomeiwen.com/subject/soortqtx.html