欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

TP多条件查询实例

程序员文章站 2023-12-31 21:17:04
where条件查询,时间范围查询 $condition = [ ['member_id', '=', $member_id] ]; if($type) { $condition[] = ['type', '=', $type]; } if ($start_time) { $condition[] = ......

where条件查询,时间范围查询

$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();

上一篇:

下一篇: