方式一
直接传入数组
$where = array();if (!empty($status))$where[] = array('status', '=', $status);if (!empty($auid))$where[] = array('auid', '=', $auid);
::相同的字段的多次查询条件可能会合并
方式二
数组对象查询
需要 实例化Where()
use think\db\Where;
$where = new Where();if ($start_time > 0 && $end_time > 0)$where['s.create_time'] = array('between', [$start_time, $end_time]);if (!empty($status))$where['s.status'] = array('=', $status);if ($user_id > 0)$where['s.auid'] = array('=', $user_id);