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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容