正在显示
4 个修改的文件
包含
33 行增加
和
5 行删除
@@ -46,11 +46,19 @@ class Home extends Base { | @@ -46,11 +46,19 @@ class Home extends Base { | ||
46 | $folder_id = (int) app()->request('folder_id'); | 46 | $folder_id = (int) app()->request('folder_id'); |
47 | // 附件 | 47 | // 附件 |
48 | $attachment = app()->request('attachment'); | 48 | $attachment = app()->request('attachment'); |
49 | + // 已读/未读 | ||
50 | + $seen = app()->request('seen',-1,'intval'); | ||
51 | + | ||
49 | 52 | ||
50 | $where = ['email_id'=>$this->getEmails('id')]; | 53 | $where = ['email_id'=>$this->getEmails('id')]; |
54 | + //目录 | ||
51 | if($folder_id) $where['folder_id'] = $folder_id; | 55 | if($folder_id) $where['folder_id'] = $folder_id; |
52 | if($ids) $where['id'] = $ids; | 56 | if($ids) $where['id'] = $ids; |
53 | if($attachment) $where['is_file'] = 1; //附件 | 57 | if($attachment) $where['is_file'] = 1; //附件 |
58 | + // 已读/未读 | ||
59 | + if(in_array($seen,[0,1])){ | ||
60 | + $where['seen'] = $seen; | ||
61 | + } | ||
54 | 62 | ||
55 | $lists = db()->all( | 63 | $lists = db()->all( |
56 | listsSql::lists( | 64 | listsSql::lists( |
@@ -132,6 +140,9 @@ class Home extends Base { | @@ -132,6 +140,9 @@ class Home extends Base { | ||
132 | app()->e('sync_request_param_error'); | 140 | app()->e('sync_request_param_error'); |
133 | }else{ | 141 | }else{ |
134 | // 查询id | 142 | // 查询id |
143 | + if(count($emails)===1){ | ||
144 | + $emails = $emails[0]; | ||
145 | + } | ||
135 | $datas = db()->all(emailSql::getValues(['email'=>$emails],'`id`,`email`,`pwd_error`')); | 146 | $datas = db()->all(emailSql::getValues(['email'=>$emails],'`id`,`email`,`pwd_error`')); |
136 | foreach ($datas as $k=>$v){ | 147 | foreach ($datas as $k=>$v){ |
137 | if(!$v['pwd_error']){ | 148 | if(!$v['pwd_error']){ |
@@ -145,7 +145,13 @@ function dbWhere(array $where, string $ar = 'and'):string{ | @@ -145,7 +145,13 @@ function dbWhere(array $where, string $ar = 'and'):string{ | ||
145 | $v = array_map(function ($n){ | 145 | $v = array_map(function ($n){ |
146 | return "'".addslashes($n)."'"; | 146 | return "'".addslashes($n)."'"; |
147 | },$v); | 147 | },$v); |
148 | - $sql[] = "`{$f}` in (".implode(',',$v).")"; | 148 | + if(count($v)===1){ |
149 | + // 只有一个值时就是 = | ||
150 | + $sql[] = "`{$f}` = ".$v; | ||
151 | + }elseif (count($v) > 1){ | ||
152 | + $sql[] = "`{$f}` in (".implode(',',$v).")"; | ||
153 | + } | ||
154 | + | ||
149 | }else{ | 155 | }else{ |
150 | $sql[] = "`{$f}` = '".addslashes($v)."'"; | 156 | $sql[] = "`{$f}` = '".addslashes($v)."'"; |
151 | } | 157 | } |
@@ -65,18 +65,29 @@ class DbPool { | @@ -65,18 +65,29 @@ class DbPool { | ||
65 | }else{ | 65 | }else{ |
66 | $params = null; | 66 | $params = null; |
67 | } | 67 | } |
68 | + | ||
69 | + if(APP_DEBUG) { | ||
70 | + $timer = microtime(true); | ||
71 | + } | ||
72 | + | ||
68 | $query = $this->client->prepare($sql); | 73 | $query = $this->client->prepare($sql); |
69 | 74 | ||
75 | + $ret = $query->execute($params); | ||
76 | + | ||
77 | + | ||
78 | + | ||
70 | if(APP_DEBUG){ | 79 | if(APP_DEBUG){ |
80 | + $timer2 = microtime(true); | ||
81 | + | ||
71 | // todo:: 记录日志,生产请注释 | 82 | // todo:: 记录日志,生产请注释 |
83 | + $sql = '['.substr($timer2-$timer,0,8).'ms] '.$sql; | ||
72 | logs( | 84 | logs( |
73 | $params ? [$sql,$params] : $sql, | 85 | $params ? [$sql,$params] : $sql, |
74 | - LOG_PATH.'/sql.log' | 86 | + LOG_PATH.'/'.date('Y-m-d').'.sql.log' |
75 | ); | 87 | ); |
76 | } | 88 | } |
77 | 89 | ||
78 | - | ||
79 | - if($query->execute($params)){ | 90 | + if($ret){ |
80 | return $query; | 91 | return $query; |
81 | } | 92 | } |
82 | 93 |
@@ -31,7 +31,7 @@ class listsSql { | @@ -31,7 +31,7 @@ class listsSql { | ||
31 | 31 | ||
32 | $filed = '`id`,`uid`,`msgno`,`subject`,`from`,`from_name`,`to`,`date`,`size`,`recent`,`flagged`,`answered`,`deleted`,`seen`,`draft`,`udate`,`folder_id`,`is_file`,`cc`,`bcc`,`description`'; | 32 | $filed = '`id`,`uid`,`msgno`,`subject`,`from`,`from_name`,`to`,`date`,`size`,`recent`,`flagged`,`answered`,`deleted`,`seen`,`draft`,`udate`,`folder_id`,`is_file`,`cc`,`bcc`,`description`'; |
33 | 33 | ||
34 | - return "select {$filed} from `".static::$table."` where ".$where." order by `udate` desc limit {$size} offset ".(($p-1)*30); | 34 | + return "select {$filed} from `".static::$table."` where ".$where." order by `udate` desc limit {$size} offset ".(($p-1)*$size); |
35 | 35 | ||
36 | } | 36 | } |
37 | 37 |
-
请 注册 或 登录 后发表评论