Thinkphp6 where 高级用法记录

如果你特别迷恋一个人,那你肯定配不上ta。

 

在使用model  进行where 链式操作的时候,where  很多用法

一般的常规使用方法

 eg:

->where('id', 1)

 

->where('id', '=', 1)

 

$where = ['id', '=', 1];

->where($where)

 

$where = [

  ['id', '=', 1]

]

->where($where)

 

高级使用方法:

$attrWhere = [
  ['sku_id', 'in', $skuIds],
  ['value_name', 'LIKE', ['%颜色%', '%尺寸%'], 'OR'],
];

->where($attrWhere)

 

字段值进行比较的时候

['total_score', 'exp', $this->db->raw('>= today_score')],

这里面的 第三个数组数据,必须使用 $this->db->raw() 进行处理,否则会报错

 

posted @ 2021-09-10 09:00  方达达  阅读(1329)  评论(0编辑  收藏  举报