CommentModel.class.php 2.11 KB
<?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[] = "`{$this->prefield}status`<?";
        $params[] = $this->get_st_delete();

        $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[] = "`{$this->prefield}status`<?";
        $params[] = $this->get_st_delete();

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

}