PaperTempModel.class.php
2.77 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
* 试卷题目对应关系表
* @author: houyingcai
* @email: 594609175@qq.com
* @date : 2017-05-19 18:05:58
*/
namespace Common\Model;
class PaperTempModel extends AbstractModel
{
/**
* 构造方法
*/
public function __construct()
{
parent::__construct();
}
/**
* 根据条件查询备选试题列表
*
* @author daijun
* @param array $conds 查询条件
* @param null $page_option 分页参数
* @param array $order_option 排序参数
* @param string $fields 查询字段
*
* @return array|bool
*/
public function list_by_where($conds = [], $page_option = null, $order_option = [], $fields = '*')
{
$params = [];
// 条件
$wheres = [];
if (!$this->_parse_where($wheres, $params, $conds)) {
return false;
}
// 企业标记
$wheres[] = "a.domain=?";
$params[] = QY_DOMAIN;
// 状态条件
$wheres[] = "a.status<?";
$params[] = $this->get_st_delete();
// 企业标记
$wheres[] = "b.domain=?";
$params[] = QY_DOMAIN;
// 状态条件
$wheres[] = "b.status<?";
$params[] = $this->get_st_delete();
// 排序
$orderby = '';
if (!$this->_order_by($orderby, $order_option)) {
return false;
}
// 分页参数
$limit = '';
if (!$this->_limit($limit, $page_option)) {
return false;
}
$sql = "SELECT {$fields} FROM __TABLE__ AS a LEFT JOIN oa_exam_topic AS b ON a.et_id=b.et_id WHERE " . implode(' AND ',
$wheres) . "{$orderby}{$limit}";
// 读取记录
return $this->_m->fetch_array($sql, $params);
}
/**
* 根据条件查询备选试题总数
*
* @author daijun
* @param array $conds 查询条件
* @param string $fields
*
* @return array|bool
*/
public function count_by_where($conds = [], $fields = '*')
{
$params = [];
// 更新条件
$wheres = [];
if (!$this->_parse_where($wheres, $params, $conds)) {
return false;
}
// 企业标记
$wheres[] = "a.domain=?";
$params[] = QY_DOMAIN;
// 状态条件
$wheres[] = "a.status<?";
$params[] = $this->get_st_delete();
// 企业标记
$wheres[] = "b.domain=?";
$params[] = QY_DOMAIN;
// 状态条件
$wheres[] = "b.status<?";
$params[] = $this->get_st_delete();
$sql = "SELECT COUNT(" . $fields . ") FROM __TABLE__ AS a LEFT JOIN oa_exam_topic AS b ON a.et_id=b.et_id WHERE " . implode(" AND ",
$wheres);
return $this->_m->result($sql, $params);
}
}