审查视图

model/emailSql.php 1.6 KB
1  
邓超 authored
1 2
<?php
1  
邓超 authored
3 4 5 6 7 8 9
namespace Model;

/**
 * @author:dc
 * @time 2023/2/13 14:11
 * Class email
 */
1  
邓超 authored
10
class emailSql {
1  
邓超 authored
11
1  
邓超 authored
12 13
    public static $table = 'emails';
1  
邓超 authored
14 15 16 17

    /**
     * 通过email查询
     * @param $email
1  
邓超 authored
18
     * @return string
1  
邓超 authored
19 20 21
     * @author:dc
     * @time 2023/2/13 14:50
     */
1  
邓超 authored
22 23 24 25
    public static function first($email, $filed='*'):string {
        return "select {$filed} from `".static::$table."` where `".(is_numeric($email) ? 'id' : 'email')."` = '{$email}' limit 1";
    }
1  
邓超 authored
26 27

1  
邓超 authored
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
    /**
     * 统计邮箱的数量
     * @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 {
1  
邓超 authored
47
        return [
1  
邓超 authored
48
            "select `id` from `".static::$table."` where `email` = ? limit 1",
1  
邓超 authored
49 50 51 52 53 54
            [
                $email
            ]
        ];
    }
1  
邓超 authored
55 56 57 58 59 60 61 62
    /**
     * 获取字段值
     * @param $where
     * @param string $field
     * @return string
     * @author:dc
     * @time 2023/3/10 10:46
     */
1  
邓超 authored
63
    public static function getValues(array $where,$field='`id`'){
1  
邓超 authored
64
        return "select {$field} from `".static::$table."` where ".dbWhere($where);
1  
邓超 authored
65
    }
1  
邓超 authored
66 67

1  
邓超 authored
68
    /**
1  
邓超 authored
69 70
     * 查询列表
     * @param string $where
1  
邓超 authored
71 72
     * @return string
     * @author:dc
1  
邓超 authored
73
     * @time 2023/3/17 16:32
1  
邓超 authored
74
     */
1  
邓超 authored
75 76
    public static function all(string $where){
        return "select * from ".static::$table." where ".$where;
1  
邓超 authored
77 78
    }
1  
邓超 authored
79 80

1  
邓超 authored
81
}