listsSql.php 1.8 KB
<?php

namespace Model;

/**
 * 邮件列表
 * @author:dc
 * @time 2023/2/17 14:15
 * Class lists
 * @package Model
 */
class listsSql {

    /**
     * 表
     * @var string
     */
    public static $table = 'lists';


    /**
     * 查询列表
     * @param $email_id
     * @param $p
     * @param int $folder_id
     * @return string
     * @author:dc
     * @time 2023/2/17 14:42
     */
    public static function lists($email_id, $p, $folder_id = null){

        $where = ['email_id'=>$email_id];
        if($folder_id) $where['folder_id'] = $folder_id;

        return "select * from `".static::$table."` where ".dbWhere($where)." order by `udate` desc limit 30 offset ".(($p-1)*30);

    }

    /**
     * 获取最后一条更新的msgno
     * @param $email_id
     * @param $folder_id
     * @return string
     * @author:dc
     * @time 2023/2/18 10:01
     */
    public static function lastMsgno($email_id,$folder_id):string{
        return "select max(`msgno`) from `".self::$table."` where ".dbWhere(['email_id'=>$email_id,'folder_id'=>$folder_id])." limit 1";
    }

    /**
     * 获取已存在的id
     * @param $email_id
     * @param $folder_id
     * @param $msgno
     * @return string
     * @author:dc
     * @time 2023/2/18 10:08
     */
    public static function getIds($email_id,$folder_id,$msgno):string {
        return "select `id`,`msgno` from `".static::$table."` where ".dbWhere([
            'email_id' =>  $email_id,
            'folder_id' =>  $folder_id,
            'msgno' =>  $msgno,
            ]);
    }

    /**
     * 通过uuid查询id和email_id
     * @param $uuid
     * @return string
     * @author:dc
     * @time 2023/2/18 10:44
     */
    public static function hasUuid($uuid):string {
        return "select `id`,`email_id`,`uuid` from `".self::$table."` where ".dbWhere(['uuid'=>$uuid]);
    }




}