thinkphp DB查询怎么使用多条件or?

以下代码查询type=15 如果想改成查询type=15以及type=16 如何修改?
尝试使用whereor发现不对。

$where['status'] = array('=', 1);//status
$where['type'] = array('=', 15);//type
$orderby = 'id desc';
最佳答案
$where['type'] = array('in', [15, 16]);
->where('status', 1)
->where(function ($query) {
  $query->where('type', 15)->whereOr('type', 16)
})
6个月前 评论
go786 (楼主) 6个月前
讨论数量: 3
$where['type'] = array('in', [15, 16]);
->where('status', 1)
->where(function ($query) {
  $query->where('type', 15)->whereOr('type', 16)
})
6个月前 评论
go786 (楼主) 6个月前

更简单的

where('type', 'in', [15, 16]);
6个月前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!