TP多條件查詢實例

where條件查詢,時間範圍查詢this

$condition = [
    ['member_id', '=', $member_id]
];
if($type) {
    $condition[] = ['type', '=', $type];
}
if ($start_time) {
    $condition[] = ['active_time', '>=', $start_time];
}
if ($end_time) {
    $condition[] = ['active_time', '<', $end_time];
}
$list = $this->where($condition)->field($field)->select();
相關文章
相關標籤/搜索