listsSql.php
2.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
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
<?php
namespace Model;
/**
* 邮件列表
* @author:dc
* @time 2023/2/17 14:15
* Class lists
* @package Model
*/
class listsSql {
/**
* 表
* @var string
*/
public static $table = 'lists';
/**
* 查询列表
* @param string $where
* @param int $p
* @param int $size
* @return string
* @author:dc
* @time 2023/3/16 18:11
*/
public static function lists(string $where, int $p, int $size){
$filed = '`id`,`uid`,`msgno`,`subject`,`from`,`from_name`,`to`,`date`,`size`,`recent`,`flagged`,`answered`,`deleted`,`seen`,`draft`,`udate`,`folder_id`,`is_file`,`cc`,`bcc`,`description`';
return "select {$filed} from `".static::$table."` where ".$where." order by `udate` desc limit {$size} offset ".(($p-1)*30);
}
/**
* 统计列表
* @param string $where
* @return string
* @author:dc
* @time 2023/3/16 18:10
*/
public static function listCount(string $where){
return "select count(*) from `".static::$table."` where ".$where;
}
/**
* 获取最后一条更新的msgno
* @param $email_id
* @param $folder_id
* @return string
* @author:dc
* @time 2023/2/18 10:01
*/
public static function lastMsgno($email_id,$folder_id):string{
return "select max(`msgno`) from `".self::$table."` where ".dbWhere(['email_id'=>$email_id,'folder_id'=>$folder_id])." limit 1";
}
/**
* 获取已存在的id
* @param $email_id
* @param $folder_id
* @param $msgno
* @return string
* @author:dc
* @time 2023/2/18 10:08
*/
public static function getIds($email_id,$folder_id,$msgno):string {
return "select `id`,`msgno` from `".static::$table."` where ".dbWhere([
'email_id' => $email_id,
'folder_id' => $folder_id,
'msgno' => $msgno,
]);
}
/**
* 通过uuid查询id和email_id
* @param $uuid
* @return string
* @author:dc
* @time 2023/2/18 10:44
*/
public static function hasUuid($uuid):string {
return "select `id`,`email_id`,`uuid` from `".self::$table."` where ".dbWhere(['uuid'=>$uuid]);
}
}