<?php namespace Common\Model; class CommentModel extends AbstractModel { /** * 构造方法 */ public function __construct() { parent::__construct(); } /** * 获取活动已参与列表数 * @author xtong * @param array $conds 条件 * @return array */ public function count_join($conds = []) { $wheres = []; $params = []; if (is_array($conds) && !empty($conds)) { $this->_parse_where($wheres, $params, $conds); } // 企业标记 $wheres[] = "`{$this->prefield}domain`=?"; $params[] = QY_DOMAIN; $wheres_sql = implode(' AND ', $wheres); $sql = "SELECT COUNT(`uid`) total FROM __TABLE__ WHERE {$wheres_sql} GROUP BY `uid`"; return count($this->_m->fetch_array($sql, $params)); } /** * 获取活动已参与列表 * @author xtong * @param array $conds 条件 * @param array $page_option 分页参数 * @param array $order_option 排序参数 * @return array */ public function list_join($conds = [],$page_option=[], $order_option=[]) { $wheres = []; $params = []; // 排序 $orderby = ''; if (!$this->_order_by($orderby, $order_option)) { return false; } // 分页参数 $limit = ''; if (!$this->_limit($limit, $page_option)) { return false; } if (is_array($conds) && !empty($conds)) { $this->_parse_where($wheres, $params, $conds); } // 企业标记 $wheres[] = "`{$this->prefield}domain`=?"; $params[] = QY_DOMAIN; $wheres_sql = implode(' AND ', $wheres); $sql = "SELECT `uid`,`created` FROM __TABLE__ WHERE {$wheres_sql} GROUP BY `uid` {$orderby}{$limit}"; return $this->_m->fetch_array($sql, $params); } /** * 根据条件计算数量(含已删除) * * @param array $conditions 查询条件 * @param string $fields 查询字段 * * @return array|bool */ public function count_by_conds_contain_del($conditions = [], $fields = '*') { // 初始化参数条件 $params = []; $wheres = []; if (!$this->_parse_where($wheres, $params, $conditions)) { return false; } // 企业标记 $wheres[] = "`{$this->prefield}domain`=?"; $params[] = QY_DOMAIN; return $this->_m->result('SELECT COUNT(' . $fields . ') FROM __TABLE__ WHERE ' . implode(' AND ', $wheres), $params); } }