作者 邓超

1

... ... @@ -218,13 +218,14 @@ function create_coroutine(array &$cid,int &$isRunMaxCNum,$worker_id){
function sync($worker_id=0){
// 需要同步的id
$id = redis()->lPop('sync_email_lists');
_echo($worker_id.': 协程('.co::getCid().'):抢到 '.$id);
if(!$id){
co::sleep(1);
return -1;
}
_echo($worker_id.': 协程('.co::getCid().'):抢到 '.$id);
$email = db()->first(\Model\emailSql::first($id));
if(!$email){
return 0;
... ...
... ... @@ -61,17 +61,21 @@ class Mail {
$folder['name'] = explode('/',$folder['parseFolder']);
$pid = 0;
foreach ($folder['id'] as $k=>$item){
// 插入到数据库
$pid = $db->insert(
folderSql::$table,
[
'email_id' => $email_id,
'folder' => $folder['name'][$k],
'origin_folder' => $item,
'pid' => $pid
]
,false
);
$data = [
'email_id' => $email_id,
'folder' => $folder['name'][$k],
'origin_folder' => $item,
'pid' => $pid
];
if(!$db->value(folderSql::has($data))){
// 插入到数据库
$pid = $db->insert(
folderSql::$table,
$data,
false
);
}
}
}
$db->commit();
... ...
... ... @@ -25,6 +25,17 @@ class folderSql {
}
/**
* 是否存在,存在则返回 id
* @param $where
* @return string
* @author:dc
* @time 2023/2/18 11:48
*/
public static function has($where){
return "select `id` from `".self::$table."` where ".dbWhere($where);
}
... ...