emailSql.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
namespace Model;
/**
 * @author:dc
 * @time 2023/2/13 14:11
 * Class email
 */
class emailSql {
    public static $table = 'emails';
    /**
     * 通过email查询
     * @param $email
     * @return string
     * @author:dc
     * @time 2023/2/13 14:50
     */
    public static function first($email, $filed='*'):string {
        return "select {$filed} from `".static::$table."` where `".(is_numeric($email) ? 'id' : 'email')."` = '{$email}' limit 1";
    }
    /**
     * 统计邮箱的数量
     * @return string
     * @author:dc
     * @time 2023/2/14 16:16
     */
    public static function count():string {
        return "select count(*) from `".static::$table."` limit 1";
    }
    /**
     * 邮箱是否存在的sql
     * @param string $email
     * @return array
     * @author:dc
     * @time 2023/2/17 10:15
     */
    public static function hasEmail(string $email):array {
        return [
            "select `id` from `".static::$table."` where `email` = ? limit 1",
            [
                $email
            ]
        ];
    }
    /**
     * 获取字段值
     * @param $where
     * @param string $field
     * @return string
     * @author:dc
     * @time 2023/3/10 10:46
     */
    public static function getValues($where,$field='id'){
        return "select `{$field}` from `".static::$table."` where ".dbWhere($where);
    }
    /**
     * 通过邮箱查询列表
     * @param $emails
     * @return string
     * @author:dc
     * @time 2023/3/10 15:02
     */
    public static function all($emails){
        return "select * from ".static::$table." where ".dbWhere(['email'=>$emails]);
    }
}