<?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(array $where,$field='`id`'){ return "select {$field} from `".static::$table."` where ".dbWhere($where); } /** * 查询列表 * @param string $where * @return string * @author:dc * @time 2023/3/17 16:32 */ public static function all(string $where){ return "select * from ".static::$table." where ".$where; } }