Yii2 where

  1. where('status=1')->  
  2. where('status=:status', [':status' => $status])->  
  3. where([  
  4.     'status' => 10,  
  5.     'type' => null,  
  6.     'id' => [4, 8, 15],  
  7. ])->  
  8. -------  
  9. $userQuery = (new Query())->select('id')->from('user');  
  10. // ...WHERE `id` IN (SELECT `id` FROM `user`)  
  11. $query->...->where(['id' => $userQuery])->...  
  12. --------  
  13. ['and''id=1''id=2'//id=1 AND id=2  
  14. ['and''type=1', ['or''id=1''id=2']] //type=1 AND (id=1 OR id=2)  
  15. ['between''id', 1, 10] //id BETWEEN 1 AND 10  
  16. ['not between''id', 1, 10] //not id BETWEEN 1 AND 10  
  17. ['in''id', [1, 2, 3]] //id IN (1, 2, 3)  
  18. ['not in''id', [1, 2, 3]] //not id IN (1, 2, 3)  
  19. ['like''name''tester'//name LIKE '%tester%'  
  20. ['like''name', ['test''sample']] //name LIKE '%test%' AND name LIKE '%sample%'  
  21. ['not like''name', ['or''test''sample']] //not name LIKE '%test%' OR not name LIKE '%sample%'  
  22. ['exists','id'$userQuery//EXISTS (sub-query) | not exists  
  23. ['>''age', 10] //age>10  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值