CourseArticleModel.class.php 1.06 KB
<?php
/**
 * Created by PhpStorm.
 * User: zhonglei
 * Date: 17/10/11
 * Time: 18:08
 */
namespace Common\Model;

class CourseArticleModel extends \Com\Model
{
    // 构造方法
    public function __construct()
    {
        parent::__construct('Article', 'oa_course_');
    }

    /**
     * 获取课程分类包含课程门数数据
     * @author zhonglei
     * @param array $conds 条件
     * @return array
     */
    public function listClassData($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(*) `total` FROM __TABLE__ WHERE {$wheres_sql} GROUP BY `class_id`";

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