<?php /** * Created by PhpStorm. * User: liyifei2012it * Date: 17/10/18 * Time: 14:39 */ namespace Common\Model; class CourseCountModel extends \Com\Model { // 构造方法 public function __construct() { parent::__construct('Count', 'oa_course_'); } /** * 获取前一天统计的所有课程可学人员总数、完成人员总数 * @author liyifei * @return array */ public function listTotal() { $wheres = []; $params = []; // 企业标记 $wheres[] = "`{$this->prefield}domain`=?"; $params[] = QY_DOMAIN; // 状态条件 $wheres[] = "`{$this->prefield}status`<?"; $params[] = $this->get_st_delete(); $wheres_sql = implode(' AND ', $wheres); $sql = "SELECT * FROM ( SELECT `count_id`, `article_id`, `user_total`, `complete_total`, `created` FROM __TABLE__ WHERE {$wheres_sql} ORDER BY `created` DESC ) as res_tab GROUP BY article_id;"; return $this->_m->fetch_array($sql, $params); } }