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