thinkphp where條件陳述式整理

來源:互聯網
上載者:User

標籤:區分   查詢條件   異或   ble   dmi   nbsp   class   支援   字串   

ThinkPHP運算子 與 SQL運算子 對照表
TP運算子 SQL運算子 例子 實際查詢條件
eq = $map[‘id‘] = array(‘eq‘,100); 等效於:$map[‘id‘] = 100;
neq != $map[‘id‘] = array(‘neq‘,100); id != 100
gt > $map[‘id‘] = array(‘gt‘,100); id > 100
egt >= $map[‘id‘] = array(‘egt‘,100); id >= 100
lt < $map[‘id‘] = array(‘lt‘,100); id < 100
elt <= $map[‘id‘] = array(‘elt‘,100); id <= 100
like like $map<‘username‘> = array(‘like‘,‘Admin%‘); username like ‘Admin%‘
between between and $map[‘id‘] = array(‘between‘,‘1,8‘); id BETWEEN 1 AND 8
not between not between and $map[‘id‘] = array(‘not between‘,‘1,8‘); id NOT BETWEEN 1 AND 8
in in $map[‘id‘] = array(‘in‘,‘1,5,8‘); id in(1,5,8)
not in not in $map[‘id‘] = array(‘not in‘,‘1,5,8‘); id not in(1,5,8)
and(預設) and $map[‘id‘] = array(array(‘gt‘,1),array(‘lt‘,10)); (id > 1) AND (id < 10)
or or $map[‘id‘] = array(array(‘gt‘,3),array(‘lt‘,10), ‘or‘); (id > 3) OR (id < 10)
xor(異或) xor 兩個輸入中只有一個是true時,結果為true,否則為false,例子略。 1 xor 1 = 0
exp 綜合運算式 $map[‘id‘] = array(‘exp‘,‘in(1,3,8)‘); $map[‘id‘] = array(‘in‘,‘1,3,8‘);

 

補充說明
  • 同 SQL 一樣,ThinkPHP運算子不區分大小寫,eq 與 EQ 一樣。
  • between、 in 條件支援字串或者數組,即下面兩種寫法是等效的:
    $map[‘id‘]  = array(‘not in‘,‘1,5,8‘);$map[‘id‘]  = array(‘not in‘,array(‘1‘,‘5‘,‘8‘));

 

thinkphp where條件陳述式整理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.