folderSql.php
1.6 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
<?php
namespace Model;
/**
* 文件夹
* @author:dc
* @time 2023/2/17 18:04
* Class folderSql
* @package Model
*/
class folderSql {
public static $table = 'folders';
/**
* 所有文件夹
* @param int|array $email_id
* @return string
* @author:dc
* @time 2023/2/18 9:22
*/
public static function all(int|array $email_id, $field = '`id`,`folder`,`pid`,`origin_folder`,`last_sync_time`'):string {
return "select {$field} from `".static::$table."` where ".dbWhere(['email_id'=>$email_id])." order by `id` asc";
}
/**
* 是否存在,存在则返回 id
* @param $where
* @return string
* @author:dc
* @time 2023/2/18 11:48
*/
public static function has($where):string {
return "select `id` from `".self::$table."` where ".dbWhere($where);
}
/**
* 查询一条完整的数据
* @param array|string $where
* @return string
* @author:dc
* @time 2023/3/14 11:49
*/
public static function first(array|string|int $where,$filed = '*'):string {
$where = is_numeric($where) ? ['id'=>$where] : $where;
return "select {$filed} from `".self::$table."` where ".dbWhere($where)." order by `id` desc limit 1";
}
/**
* 读取源文件夹
* @param int $email_id
* @param string $folder
* @return string
* @author:dc
* @time 2023/5/8 11:01
*/
public static function originFolder(int $email_id,string $folder){
return "select `origin_folder` from `".static::$table."` where `email_id` = {$email_id} and `folder` = '{$folder}' order by `id` desc limit 1";
}
}