作者 邓超

1

... ... @@ -46,11 +46,19 @@ class Home extends Base {
$folder_id = (int) app()->request('folder_id');
// 附件
$attachment = app()->request('attachment');
// 已读/未读
$seen = app()->request('seen',-1,'intval');
$where = ['email_id'=>$this->getEmails('id')];
//目录
if($folder_id) $where['folder_id'] = $folder_id;
if($ids) $where['id'] = $ids;
if($attachment) $where['is_file'] = 1; //附件
// 已读/未读
if(in_array($seen,[0,1])){
$where['seen'] = $seen;
}
$lists = db()->all(
listsSql::lists(
... ... @@ -132,6 +140,9 @@ class Home extends Base {
app()->e('sync_request_param_error');
}else{
// 查询id
if(count($emails)===1){
$emails = $emails[0];
}
$datas = db()->all(emailSql::getValues(['email'=>$emails],'`id`,`email`,`pwd_error`'));
foreach ($datas as $k=>$v){
if(!$v['pwd_error']){
... ...
... ... @@ -145,7 +145,13 @@ function dbWhere(array $where, string $ar = 'and'):string{
$v = array_map(function ($n){
return "'".addslashes($n)."'";
},$v);
if(count($v)===1){
// 只有一个值时就是 =
$sql[] = "`{$f}` = ".$v;
}elseif (count($v) > 1){
$sql[] = "`{$f}` in (".implode(',',$v).")";
}
}else{
$sql[] = "`{$f}` = '".addslashes($v)."'";
}
... ...
... ... @@ -65,18 +65,29 @@ class DbPool {
}else{
$params = null;
}
if(APP_DEBUG) {
$timer = microtime(true);
}
$query = $this->client->prepare($sql);
$ret = $query->execute($params);
if(APP_DEBUG){
$timer2 = microtime(true);
// todo:: 记录日志,生产请注释
$sql = '['.substr($timer2-$timer,0,8).'ms] '.$sql;
logs(
$params ? [$sql,$params] : $sql,
LOG_PATH.'/sql.log'
LOG_PATH.'/'.date('Y-m-d').'.sql.log'
);
}
if($query->execute($params)){
if($ret){
return $query;
}
... ...
... ... @@ -31,7 +31,7 @@ class listsSql {
$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`';
return "select {$filed} from `".static::$table."` where ".$where." order by `udate` desc limit {$size} offset ".(($p-1)*30);
return "select {$filed} from `".static::$table."` where ".$where." order by `udate` desc limit {$size} offset ".(($p-1)*$size);
}
... ...