/** *某网台的 节目单做(创建)取最新五条记录作为网台记录 * @param $sta_id * @return $ret 节目单信息 */ private function update_station_program($sta_id = 0, $is_count = false) { $mInfo = $this->mUser->verify_credentials(); $user_id = $mInfo['id']; //当前的ID $info = array("sta_id" => $sta_id, "user_id" => $user_id, "programe" => "", "update_time" => TIMENOW, "ip" => hg_getip()); if ($info['sta_id']) { $sql = $sql = "SELECT count(*) as total FROM " . DB_PREFIX . "network_programme WHERE sta_id =" . $info['sta_id']; $f = $this->db->query_first($sql); $total = $f['total']; $sql = "SELECT id,user_id,sta_id,video_id,programe_name,start_time,end_time,create_time,update_time,order_id FROM " . DB_PREFIX . "network_programme WHERE sta_id =" . $info['sta_id'] . " ORDER BY update_time DESC LIMIT 0,4"; $q = $this->db->query($sql); $video_id = ""; $user_id = ""; $space = ""; while ($row = $this->db->fetch_array($q)) { $program[$row['id']] = $row; $video_id .= $space . $row['video_id']; $user_id .= $row['user_id'] . ","; $space = ","; } $user = $this->mVideo->getUserById($user_id); if ($video_id) { $sql = "SELECT id,user_id,sort_id,title,tags,schematic,bschematic,filename,streaming_media,toff,copyright,collect_count,comment_count,play_count,click_count,is_top,state,bans,ip,create_time,update_time,is_show,serve_id,is_recommend,is_thread FROM " . DB_PREFIX . "video WHERE id IN(" . $video_id . ")"; $q = $this->db->query($sql); while ($row = $this->db->fetch_array($q)) { if ($row['id']) { $row = hg_video_image($row['id'], $row); $video[$row['id']] = $row; } } } if (is_array($program)) { foreach ($program as $key => $value) { $program[$key]['user'] = $user[$value['user_id']]; if ($video_id) { $program[$key]['video'] = $video[$value['video_id']]; } } // $program['total'] = $total; } $con = ''; switch ($is_count) { case 1: $con = ', program_count=program_count+1 '; break; case 2: $con = ', program_count=program_count-1 '; break; default: break; } $info['programe'] = hg_filter_chars(serialize($program)); $sql = "UPDATE " . DB_PREFIX . "network_station SET programe='" . $info['programe'] . "',update_time =" . $info['update_time'] . $con . " WHERE id=" . $info['sta_id']; $this->db->query($sql); return true; } return false; }
/** * 重建所有网台中program中的program信息 * */ public function reset_program_history() { $sql = "SELECT id FROM " . DB_PREFIX . "network_station WHERE program_count > 0"; $query = $this->db->query($sql); while ($r = $this->db->fetch_array($query)) { $info = array("sta_id" => $r['id'], "programe" => "", "update_time" => time(), "ip" => hg_getip()); if ($info['sta_id']) { $sql = "SELECT id,user_id,sta_id,video_id,programe_name,start_time,end_time,create_time,update_time FROM " . DB_PREFIX . "network_programme WHERE sta_id =" . $info['sta_id'] . " ORDER BY update_time DESC LIMIT 0,4"; $q = $this->db->query($sql); $video_id = ""; $user_id = ""; $space = ""; while ($row = $this->db->fetch_array($q)) { $program[$row['id']] = $row; $video_id .= $space . $row['video_id']; $user_id = $row['user_id']; $space = ","; } if ($user_id) { $user = $this->mVideo->getUserById($user_id); } if ($video_id) { $sql = "SELECT id,user_id,sort_id,title,tags,schematic,bschematic,filename,streaming_media,toff,copyright,collect_count,comment_count,play_count,click_count,is_top,state,bans,ip,create_time,update_time,is_show,serve_id,is_recommend,is_thread FROM " . DB_PREFIX . "video WHERE state=1 AND is_show=2 AND id IN(" . $video_id . ")"; $q = $this->db->query($sql); while ($row = $this->db->fetch_array($q)) { if ($row['id']) { $row = hg_video_image($row['id'], $row); $video[$row['id']] = $row; } } } if (is_array($program) && $video) { foreach ($program as $key => $value) { $program[$key]['user'] = $user[$value['user_id']]; if ($video[$value['video_id']]) { $program[$key]['video'] = $video[$value['video_id']]; } else { unset($program[$key]); } } $info['programe'] = hg_filter_chars(serialize($program)); $sql = "UPDATE " . DB_PREFIX . "network_station SET programe='" . $info['programe'] . "',update_time =" . $info['update_time'] . " WHERE id=" . $info['sta_id']; $this->db->query($sql); } unset($info, $program, $video); } } }