thinkphp5拼接数组查询条件
2023-03-29 23:03:03
176
{{single.collect_count}}

方式一

直接传入数组

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

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}