作者 邓超

优化

... ... @@ -41,7 +41,11 @@ class listsSql {
* @time 2023/3/17 16:24
*/
public static function first($db,string $where,$filed='*', $throw=false) {
if(is_array($where)){
$where = dbWhere($where);
}elseif (is_numeric($where)) {
$where = dbWhere(['id' => $where]);
}
foreach ([self::$table,"lists_back","lists_hot"] as $table) {
$sql = "select {$filed} from `".$table."` where ".$where.' limit 1';
if($throw){
... ... @@ -58,7 +62,31 @@ class listsSql {
}
public static function maxUid($db,string $where){
if(is_array($where)){
$where = dbWhere($where);
}elseif (is_numeric($where)) {
$where = dbWhere(['id' => $where]);
}
$uid = 0;
foreach ([self::$table,"lists_back",/*"lists_hot"*/] as $table) {
$sql = "select max(`uid`) as `mc` from `".$table."` where ".$where;
$data = $db->value($sql);
if($data) {
$uid = max($uid, $data);
}
}
return $uid;
}
public static function count($db,string $where){
if(is_array($where)){
$where = dbWhere($where);
}elseif (is_numeric($where)) {
$where = dbWhere(['id' => $where]);
}
$num = 0;
foreach ([self::$table,"lists_back",/*"lists_hot"*/] as $table) {
$sql = "select count(*) as `mc` from `".$table."` where ".$where;
... ...
... ... @@ -455,15 +455,10 @@ class SyncMail {
if($this->isStop) return $sync_number;
if($this->isUid){
$maxUid = listsSql::first($this->db,dbWhere([
$maxUid = listsSql::maxUid($this->db,dbWhere([
'email_id'=>$this->emailId(),
'folder_id'=>$folder_id,
]),'max(`uid`) as `uid`');
if($maxUid && $maxUid['uid']){
$maxUid = $maxUid['uid'];
}else {
$maxUid = 0;
}
]));
$maxUid = $maxUid?$maxUid:0;
if($this->isUid==1&&!$maxUid){
return 0;
... ...