ImportDataModel.class.php
1.67 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
<?php
/**
* Created by IntelliJ IDEA.
* User: zhuxun37
* Date: 2017/5/17
* Time: 上午11:46
*/
namespace Common\Model;
class ImportDataModel extends AbstractModel
{
// 导入结果: 未知
const IS_ERROR_TYPE_UNKNOWN = 0;
// 导入结果: 已出错
const IS_ERROR_TYPE_ERROR = 1;
// 数据类型, title: excel表头
const DATA_TYPE_TITLE = 'title';
// 构造方法
public function __construct()
{
parent::__construct();
}
/**
* 获取错误列表,并返回title信息
*
* @param array $conds 条件数组
* @param array $order_option 排序
*
* @return array|bool
*/
public function list_import_data_by_conds($conds, $order_option = array())
{
$where = 'domain=? AND status<? ';
$params = array(
QY_DOMAIN,
self::ST_DELETE
);
if (!empty($conds['import_flag'])) {
$where .= ' AND import_flag = ?';
$params[] = $conds['import_flag'];
}
if (!empty($conds['ea_id'])) {
$where .= ' AND ea_id = ?';
$params[] = $conds['ea_id'];
}
if (!empty($conds['is_error'])) {
// 获取title
$where .= ' AND (data_type = ?';
$params[] = self::DATA_TYPE_TITLE;
$where .= ' or is_error = ?)';
$params[] = $conds['is_error'];
}
// 排序
$orderby = '';
if (!$this->_order_by($orderby, $order_option)) {
return false;
}
$sql = 'SELECT * FROM __TABLE__ WHERE ' . $where . ' ' . $orderby;
return $this->_m->fetch_array($sql, $params);
}
}