CourseExamModel.class.php
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* Created by PhpStorm.
* User: zhonglei
* Date: 17/10/13
* Time: 18:41
*/
namespace Common\Model;
class CourseExamModel extends \Com\Model
{
// 构造方法
public function __construct()
{
parent::__construct('Exam', 'oa_course_');
}
/**
* 获取用户课程测评次数排行
* @author zhonglei
* @param array $conds 条件
* @param int $limit 数据总数,0为取所有数据
* @return array
*/
public function listUserRank($conds, $limit = 0)
{
$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 `uid` ORDER BY `total` DESC";
if ($limit > 0) {
$sql .= " LIMIT {$limit}";
}
return $this->_m->fetch_array($sql, $params);
}
}