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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM