CourseSourceModel.class.php 1.25 KB
<?php
/**
 * Created by PhpStorm.
 * User: liyifei2012it
 * Date: 17/10/14
 * Time: 17:15
 */

namespace Common\Model;

class CourseSourceModel extends \Com\Model
{

    // 构造方法
    public function __construct()
    {
        parent::__construct('Source', 'oa_course_');
    }

    /**
     * 新增各类型素材数
     * @author liyifei
     * @param int $starttime 开始时间
     * @param int $endtime 结束时间
     * @return array
     */
    public function listSourceTypeTotal($starttime, $endtime)
    {
        $wheres = [];
        $params = [];

        $conds = [
            'created >= ?' => $starttime,
            'created <= ?' => $endtime,
        ];
        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 `source_type`, COUNT(`source_id`) `source_total` FROM __TABLE__ WHERE {$wheres_sql} GROUP BY `source_type`";

        return $this->_m->fetch_array($sql, $params);
    }
}