} //更新话题下的赞的数目 private function updateTopicFavorNum() { //先查询赞信息 $option = new option(); $favor = $option->get_attention('topic', 'favor'); if ($favor) { $topic_ids = array(); foreach ($favor as $k => $v) { $topic_ids[] = $k; //更新话题赞数据 $sql = 'UPDATE `liv_topic` SET `favor_num` = ' . count($v) . ' WHERE topic_id = ' . $k; $result = $this->db->query($sql); } if ($topic_ids) { $sql = 'SELECT topic_id, state, type_state FROM `liv_topic` WHERE topic_id in (' . implode(',', $topic_ids) . ')'; $query = $this->db->query($sql); $info = array(); $type = $state = array(); while ($row = $this->db->fetch_array($query)) { $info[] = $row['topic_id']; $state[$row['topic_id']] = $row['state']; $type[$row['topic_id']] = $row['type_state']; } $del_ids = ''; $set_true = ''; $set_false = ''; $update_ids = array(); if ($info && $state && $type) { foreach ($topic_ids as $v) { if (!in_array($k, $info)) { $dp = $del_ids ? "," : ""; $del_ids .= $dp . $v; } else { if ($type[$k] == 'team') { $tp = $set_true ? "," : ""; $set_true .= $tp . $v; } else { if ($type[$k] == '' && $state[$k] == 0) { $fp = $set_false ? "," : ""; $set_false .= $fp . $v; } else { //UNTODO } } } } } $del_ids = trim($del_ids, ','); $set_true = trim($set_true, ','); $set_false = trim($set_false, ','); } $option->del_attention($del_ids, $set_true, $set_false, 'topic'); }