email.php 1.5 KB
<?php

namespace Model;

/**
 * @author:dc
 * @time 2023/2/13 14:11
 * Class email
 */
class email {

    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 $data
     * @param $where
     * @return array
     * @author:dc
     * @time 2023/2/17 10:24
     */
    public static function update($data,$where){

        return [
            "update `".static::$table."` set ". dbUpdate($data)
            ." where ".(is_numeric($where) ? '`id` = '.$where : dbWhere($where)),
            $data
        ];

    }


    public function insert(){

    }






}