- <?php
- require_once 'config.php';
- define('MEMCACHE_PREFIX', 'gamesort');
- define('MEMCACHE_PARTITION', '|');
- define('MEMCACHE_TIME', 600);
- $RankPerKey = REGION_PREFIX . MEMCACHE_PARTITION. MEMCACHE_PREFIX .MEMCACHE_PARTITION;
- $metaData = array(
- 'page' => 50 ,
- 'order' => '',
- 'limit' => 50 ,
- );
- function cacheRankInfo($sortType){
- global $RankPerKey;
- $dbData = array();
- switch ($sortType)
- {
- case 1:
- $dbData = fetchBodyRank();
- break;
- case 2:
- $dbData = fetchSoulRank();
- break;
- case 3:
- $dbData = fetchTrumpRank();
- break;
- case 4:
- $dbData = fetchPetRank();
- break;
- case 5:
- $dbData = fetchGuildRank();
- break;
- case 6:
- $dbData = fetchPkRank();
- break;
- case 7:
- $dbData = fetchFurnishmentRank();
- break;
- case 8:
- $dbData = fetchFortuneRank();
- break;
- case 9:
- $dbData = fetchAbilityRank();
- break;
- case 10:
- $dbData = fetchFlypetRank();
- break;
- case 11:
- $dbData = fetchRidepetRank();
- break;
- case 12:
- $dbData = fetchChanllengeRank();
- break;
- case 13:
- $dbData = fetchRemedyRank();
- break;
- case 14:
- $dbData = fetchMonsterRank();
- break;
- case 15:
- $dbData = fetchWeaponRank();
- break;
- default:
- return;
- }
-
- //print_r($dbData);
- if(count($dbData) < 1) return;
- $perKey = $RankPerKey . $sortType . MEMCACHE_PARTITION;
- $sortData = fetchPageData($dbData, $perKey);
- //print_r($sortData);
- $shopXmlData = parseToXml($sortData);
- saveToCache($shopXmlData);
- return $shopXmlData;
- //clearCache($shopXmlData);
- }
- //武器排行
- function fetchWeaponRank ()
- {
- global $metaData;
-
- $data = array();
- $dB = dbConnect();
-
- $query = "SELECT char_oid,sort_effect_val1,sort_para FROM char_stat_sort WHERE sort_type = 15 ORDER BY `sort_effect_val1` DESC , `sort_effect_val2` DESC ";
- $query .= " limit ". $metaData['limit'];
- $result = $dB->query($query);
-
- $objUidList = "";
- $rank = 0;
- $minVal = 0;
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $rank++;
- if($objUidList != ""){
- $objUidList = $objUidList . ",";
- }
- $objUidList = $objUidList . "'" . $row["char_oid"] . "'";
- $data[] = array(
- 'rank' => $rank,
- 'weapon_type' => $row['sort_para'],
- 'quality' => $row['sort_effect_val1'],
- 'char_oid' => $row['char_oid'],
- );
-
- if ($rank == $metaData['limit']) $minVal = $row["sort_effect_val1"];
- }
-
- $query = "UPDATE char_rank_params SET rank_val1_min = " . $minVal . " where rank_type = 15";
- $dB->query($query);
-
- if ($objUidList == ""){
- $dB->close();
- return array();
- }
-
- $query = "SELECT char_oid, name FROM char_data WHERE char_oid in (" . $objUidList .")";
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $charName[$row['char_oid']] = $row["name"];
- }
- foreach($data as $key => $row){
- $data[$key]['name'] = $charName[$row['char_oid']];
- }
-
- $dB->close();
- return $data;
- }
- //万妖窟排行
- function fetchMonsterRank ()
- {
- global $metaData;
-
- $data = array();
- $dB = dbConnect();
-
- $query = "SELECT char_oid,sort_effect_val1 FROM char_stat_sort WHERE sort_type = 14 ORDER BY `sort_effect_val1` DESC , `sort_effect_val2` DESC ";
- $query .= " limit ". $metaData['limit'];
- $result = $dB->query($query);
-
- $objUidList = "";
- $rank = 0;
- $minVal = 0;
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $rank++;
- if($objUidList != ""){
- $objUidList = $objUidList . ",";
- }
- $objUidList = $objUidList . "'" . $row["char_oid"] . "'";
- $data[$row["char_oid"]]['endless'] = $row["sort_effect_val1"];
- $data[$row["char_oid"]]['rank'] = $rank;
- $data[$row["char_oid"]]['char_oid'] = $row["char_oid"];
-
- if ($rank == $metaData['limit']) $minVal = $row["sort_effect_val1"];
- }
-
- $query = "UPDATE char_rank_params SET rank_val1_min = " . $minVal . " where rank_type = 14";
- $dB->query($query);
-
- if ($objUidList == ""){
- $dB->close();
- return array();
- }
-
- $query = "SELECT char_oid, name FROM char_data WHERE char_oid in (" . $objUidList .")";
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $data[$row["char_oid"]]["name"] = $row["name"];
- }
-
- $dB->close();
- return $data;
- }
- function fetchRemedyRank ()
- {
- global $metaData;
-
- $data = array();
- $dB = dbConnect();
-
- $query = "SELECT char_oid,sort_effect_val1 FROM char_stat_sort WHERE sort_type = 13 ORDER BY `sort_effect_val1` DESC , `sort_effect_val2` DESC ";
- $query .= " limit ". $metaData['limit'];
- $result = $dB->query($query);
-
- $objUidList = "";
- $rank = 0;
- $minVal = 0;
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $rank++;
- if($objUidList != ""){
- $objUidList = $objUidList . ",";
- }
- $objUidList = $objUidList . "'" . $row["char_oid"] . "'";
- $data[$row["char_oid"]]['remedy'] = $row["sort_effect_val1"];
- $data[$row["char_oid"]]['rank'] = $rank;
- $data[$row["char_oid"]]['char_oid'] = $row["char_oid"];
-
- if ($rank == $metaData['limit']) $minVal = $row["sort_effect_val1"];
- }
-
- $query = "UPDATE char_rank_params SET rank_val1_min = " . $minVal . " where rank_type = 13";
- $dB->query($query);
-
- if ($objUidList == ""){
- $dB->close();
- return array();
- }
-
- $query = "SELECT char_oid, name FROM char_data WHERE char_oid in (" . $objUidList .")";
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $data[$row["char_oid"]]["name"] = $row["name"];
- }
-
- $dB->close();
- return $data;
- }
- function fetchChanllengeRank(){
- global $metaData;
-
- $query = "SELECT challenge_order,school,char_oid,name FROM char_challenge ORDER BY challenge_order limit " . $metaData['limit'];
- $data = array();
- $dB = dbConnect();
- $result = $dB->query($query);
-
- $rank = 0;
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $rank++;
- $data[$rank] = $row;
- $data[$rank]["rank"] = $rank;
- }
-
- $dB->close();
- return $data;
- }
- function fetchGuildRank ()
- {
- global $metaData;
-
- $query = "SELECT a.*, char_oid FROM (SELECT guild_id,name as guild_name,level,leader_name as name,member_count as count FROM guild_data FORCE INDEX (level) ORDER BY LEVEL DESC, boom DESC";
- $query .= " limit ". $metaData['limit'] .") AS a LEFT JOIN char_data b ON ( a.name = b.name )";
- $data = array();
- $dB = dbConnect();
- $result = $dB->query($query);
-
- $rank = 0;
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $rank++;
- $data[$rank] = $row;
- $data[$rank]["rank"] = $rank;
- }
-
- $dB->close();
- return $data;
- }
- function fetchBodyRank ()
- {
- global $metaData;
-
- $data = array();
- $dB = dbConnect();
-
- $query = "SELECT object_uid,sort_effect_val1 FROM char_item_sort WHERE sort_type = 1 ORDER BY `sort_effect_val1` DESC , `sort_effect_val2` DESC ";
- $query .= " limit ". $metaData['limit'];
- $result = $dB->query($query);
-
- $objUidList = "";
- $rank = 0;
- $minVal = 0;
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $rank++;
- if($objUidList != ""){
- $objUidList = $objUidList . ",";
- }
- $objUidList = $objUidList . "'" . $row["object_uid"] . "'";
- $data[$row["object_uid"]]['level'] = $row["sort_effect_val1"];
- $data[$row["object_uid"]]['rank'] = $rank;
-
- if ($rank == $metaData['limit']) $minVal = $row["sort_effect_val1"];
- }
-
- $query = "UPDATE char_rank_params SET rank_val1_min = " . $minVal . " where rank_type = 1";
- $dB->query($query);
-
- if ($objUidList == ""){
- $dB->close();
- return array();
- }
-
- $query = "SELECT a.item_uuid, a.owner_oid, b.name FROM char_items as a, char_data b WHERE a.owner_oid = b.char_oid and a.item_uuid in (" . $objUidList .")";
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $data[$row["item_uuid"]]["name"] = $row["name"];
- $data[$row["item_uuid"]]["char_oid"] = $row["owner_oid"];
-
- // 把角色ID刷到角色物品排行表
- $sql = "UPDATE char_item_sort SET char_oid = ".$row["owner_oid"]." WHERE object_uid = '".$row["item_uuid"]."'";
- $dB->query($sql);
- }
-
- // 如果肉身数据不存在,则删除排名数据
- foreach($data as $key => $rankVal){
- if (!isset($rankVal["name"])){
- $query = "DELETE FROM char_item_sort WHERE object_uid = '" . $key . "'";
- $result = $dB->query($query);
- }
- }
-
- $dB->close();
- return $data;
- }
- function fetchSoulRank ()
- {
- global $metaData;
-
- $data = array();
- $dB = dbConnect();
-
- $query = "SELECT char_oid,sort_effect_val1 FROM char_stat_sort WHERE sort_type = 2 ORDER BY `sort_effect_val1` DESC , `sort_effect_val2` DESC ";
- $query .= " limit ". $metaData['limit'];
- $result = $dB->query($query);
-
- $objUidList = "";
- $rank = 0;
- $minVal = 0;
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $rank++;
- if($objUidList != ""){
- $objUidList = $objUidList . ",";
- }
- $objUidList = $objUidList . "'" . $row["char_oid"] . "'";
- $data[$row["char_oid"]]['level'] = $row["sort_effect_val1"];
- $data[$row["char_oid"]]['rank'] = $rank;
- $data[$row["char_oid"]]['char_oid'] = $row["char_oid"];
-
- if ($rank == $metaData['limit']) $minVal = $row["sort_effect_val1"];
- }
-
- $query = "UPDATE char_rank_params SET rank_val1_min = " . $minVal . " where rank_type = 2";
- $dB->query($query);
-
- if ($objUidList == ""){
- $dB->close();
- return array();
- }
-
- $query = "SELECT char_oid, name FROM char_data WHERE char_oid in (" . $objUidList .")";
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $data[$row["char_oid"]]["name"] = $row["name"];
- }
-
- $dB->close();
- return $data;
- }
- function fetchTrumpRank ()
- {
- global $metaData;
-
- $data = array();
- $dB = dbConnect();
-
- $query = "SELECT object_uid,sort_effect_val1,sort_effect_val2 FROM char_item_sort WHERE sort_type = 3 ORDER BY `sort_effect_val1` DESC , `sort_effect_val2` DESC ";
- $query .= " limit ". $metaData['limit'];
- $result = $dB->query($query);
-
- $objUidList = "";
- $rank = 0;
- $minVal1 = 0;
- $minVal2 = 0;
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $rank++;
- if($objUidList != ""){
- $objUidList = $objUidList . ",";
- }
- $objUidList = $objUidList . "'" . $row["object_uid"] . "'";
- $data[$row["object_uid"]]['rank'] = $rank;
- $data[$row["object_uid"]]['item_uuid'] = $row["object_uid"];
- $data[$row["object_uid"]]['quality'] = $row["sort_effect_val2"];
- $data[$row["object_uid"]]['power'] = $row["sort_effect_val1"];
-
- if ($rank == $metaData['limit']) {
- $minVal1 = $row["sort_effect_val1"];
- $minVal2 = $row["sort_effect_val2"];
- }
- }
-
- $query = "UPDATE char_rank_params SET rank_val1_min = " . $minVal1 . ", rank_val2_min = " . $minVal2 . " where rank_type = 3";
- $dB->query($query);
-
- if ($objUidList == ""){
- $dB->close();
- return array();
- }
-
- $query = "SELECT item_uuid, owner_oid, template_oid FROM char_items WHERE item_uuid in (" . $objUidList .")";
- $result = $dB->query($query);
- $charOidList = "";
- $petOidList = "";
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- if ($row["owner_oid"] < 4294967295){
- if($charOidList != ""){
- $charOidList = $charOidList . ",";
- }
- $charOidList = $charOidList . "'" . $row["owner_oid"] . "'";
- }
- else{
- if($petOidList != ""){
- $petOidList = $petOidList . ",";
- }
- $petOidList = $petOidList . "'" . $row["owner_oid"] . "'";
- }
-
- $data[$row["item_uuid"]]["template_oid"] = $row["template_oid"];
- $data[$row["item_uuid"]]["name"] = "";
- $data[$row["item_uuid"]]["owner_oid"] = $row["owner_oid"];
- $data[$row["item_uuid"]]["char_oid"] = $row["owner_oid"];
- }
-
- $oid2name = array();
- if($petOidList != ""){
- $query = "SELECT pet_oid, b.name FROM char_pets a, char_data b WHERE pet_oid in (" . $petOidList .") and a.char_oid = b.char_oid";
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $oid2name[$row["pet_oid"]] = $row["name"];
- }
- }
-
- if($charOidList != ""){
- $query = "SELECT char_oid, name FROM char_data WHERE char_oid in (" . $charOidList .")";
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $oid2name[$row["char_oid"]] = $row["name"];
- }
- }
-
- foreach($data as $key => $rankVal){
- if(isset($oid2name[$rankVal["owner_oid"]])){
- $data[$key]["name"] = $oid2name[$rankVal["owner_oid"]];
-
- // 把角色ID刷到角色物品排行表
- $sql = "UPDATE char_item_sort SET char_oid = ".$rankVal["owner_oid"]." WHERE object_uid = '".$rankVal["item_uuid"]."'";
- $dB->query($sql);
- }
- else{
- // 如果法宝数据不存在,则删除排名数据
- $query = "DELETE FROM char_item_sort WHERE object_uid = '" . $key . "'";
- $result = $dB->query($query);
- }
- }
- $dB->close();
- return $data;
- }
- function fetchPetRank ()
- {
- global $metaData;
-
- $data = array();
- $dB = dbConnect();
-
- $query = "SELECT object_uid,sort_effect_val1,sort_effect_val2 FROM char_item_sort WHERE sort_type = 4 ORDER BY `sort_effect_val1` DESC , `sort_effect_val2` DESC ";
- $query .= " limit ". $metaData['limit'];
- $result = $dB->query($query);
-
- $objUidList = "";
- $rank = 0;
- $minVal = 500;
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $rank++;
- if($objUidList != ""){
- $objUidList = $objUidList . ",";
- }
- $objUidList = $objUidList . "'" . $row["object_uid"] . "'";
- $data[$row["object_uid"]]['rank'] = $rank;
- $data[$row["object_uid"]]['pet_oid'] = $row["object_uid"];
- $data[$row["object_uid"]]['quality'] = $row["sort_effect_val2"];
- $data[$row["object_uid"]]['power'] = $row["sort_effect_val1"];
-
- if ($rank == $metaData['limit']) $minVal = $row["sort_effect_val1"];
- }
-
- $query = "UPDATE char_rank_params SET rank_val1_min = " . $minVal . " where rank_type = 4";
- $dB->query($query);
-
- if ($objUidList == ""){
- $dB->close();
- return array();
- }
-
- $query = "SELECT pet_oid, b.name as name, a.name as pname,b.char_oid as char_oid FROM char_pets a, char_data b WHERE a.char_oid = b.char_oid and pet_oid in (" . $objUidList .")";
- //print_r($query);
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $data[$row["pet_oid"]]["name"] = $row["name"];
- $data[$row["pet_oid"]]["pet_name"] = $row["pname"];
- $data[$row["pet_oid"]]["char_oid"] = $row["char_oid"];
-
- // 把角色ID刷到角色物品排行表
- $sql = "UPDATE char_item_sort SET char_oid = ".$row["char_oid"]." WHERE object_uid = '".$row["pet_oid"]."'";
- $dB->query($sql);
- }
-
- // 如果宠物数据不存在,则删除排名数据
- foreach($data as $key => $rankVal){
- if (!isset($rankVal["name"])){
- $query = "DELETE FROM char_item_sort WHERE object_uid = '" . $key . "'";
- $result = $dB->query($query);
- }
- }
-
- $dB->close();
- return $data;
- }
- function fetchPkRank ()
- {
- global $metaData;
-
- $data = array();
- $dB = dbConnect();
-
- $query = "SELECT char_oid,sort_effect_val1 FROM char_stat_sort WHERE sort_type = 6 ORDER BY `sort_effect_val1` DESC , `sort_effect_val2` DESC ";
- $query .= " limit ". $metaData['limit'];
- $result = $dB->query($query);
-
- $objUidList = "";
- $rank = 0;
- $minVal = 0;
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $rank++;
- if($objUidList != ""){
- $objUidList = $objUidList . ",";
- }
- $objUidList = $objUidList . "'" . $row["char_oid"] . "'";
- $data[$row["char_oid"]]['pk_point'] = $row["sort_effect_val1"];
- $data[$row["char_oid"]]['rank'] = $rank;
-
- if ($rank == $metaData['limit']) $minVal = $row["sort_effect_val1"];
- }
-
- $query = "UPDATE char_rank_params SET rank_val1_min = " . $minVal . " where rank_type = 6";
- $dB->query($query);
-
- if ($objUidList == ""){
- $dB->close();
- return array();
- }
-
- $query = "SELECT a.char_oid, name, b.level as blevel, c.level as slevel FROM char_data a,char_body b,char_soul c WHERE a.char_oid in (" . $objUidList .") and a.char_oid = b.char_oid and a.char_oid = c.char_oid ";
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $data[$row["char_oid"]]["name"] = $row["name"];
- $data[$row["char_oid"]]["body_level"] = $row["blevel"];
- $data[$row["char_oid"]]["soul_level"] = $row["slevel"];
- }
-
- $dB->close();
- return $data;
- }
- function fetchFurnishmentRank(){
- global $metaData;
-
- $data = array();
- $dB = dbConnect();
-
- $query = "SELECT object_uid,sort_effect_val1, sort_effect_val2 FROM char_item_sort WHERE sort_type = 7 ORDER BY `sort_effect_val1` DESC , `sort_effect_val2` DESC ";
- $query .= " limit ". $metaData['limit'];
- $result = $dB->query($query);
-
- $objUidList = "";
- $rank = 0;
- $minVal = 0;
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $rank++;
- if($objUidList != ""){
- $objUidList = $objUidList . ",";
- }
- $objUidList = $objUidList . "'" . $row["object_uid"] . "'";
- $data[$row["object_uid"]]['rank'] = $rank;
- $data[$row["object_uid"]]['item_uuid'] = $row["object_uid"];
- $data[$row["object_uid"]]['quality'] = $row["sort_effect_val2"];
- $data[$row["object_uid"]]['power'] = $row["sort_effect_val1"];
-
- if ($rank == $metaData['limit']) $minVal = $row["sort_effect_val1"];
- }
-
- $query = "UPDATE char_rank_params SET rank_val1_min = " . $minVal . " where rank_type = 7";
- $dB->query($query);
-
- if ($objUidList == ""){
- $dB->close();
- return array();
- }
-
- $query = "SELECT a.item_uuid, a.template_oid, a.owner_oid, b.name FROM char_items as a, char_data b WHERE a.owner_oid = b.char_oid and a.item_uuid in (" . $objUidList .")";
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $data[$row["item_uuid"]]["name"] = $row["name"];
- $data[$row["item_uuid"]]["char_oid"] = $row["owner_oid"];
- $data[$row["item_uuid"]]["template_oid"] = $row["template_oid"];
-
- // 把角色ID刷到角色物品排行表
- $sql = "UPDATE char_item_sort SET char_oid = ".$row["owner_oid"]." WHERE object_uid = '".$row["item_uuid"]."'";
- $dB->query($sql);
- }
- $dB->close();
- return $data;
- }
- function fetchFortuneRank(){
- global $metaData;
-
- $data = array();
- $dB = dbConnect();
-
- $query = "SELECT char_oid,sort_effect_val1 FROM char_stat_sort WHERE sort_type = 8 ORDER BY `sort_effect_val1` DESC , `sort_effect_val2` DESC ";
- $query .= " limit ". $metaData['limit'];
- $result = $dB->query($query);
-
- $objUidList = "";
- $rank = 0;
- $minVal = 0;
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $rank++;
- if($objUidList != ""){
- $objUidList = $objUidList . ",";
- }
- $objUidList = $objUidList . "'" . $row["char_oid"] . "'";
- $data[$row["char_oid"]]['rank'] = $rank;
- $data[$row["char_oid"]]['money'] = $row["sort_effect_val1"];
- $data[$row["char_oid"]]['char_oid'] = $row["char_oid"];
-
- if ($rank == $metaData['limit']) $minVal = $row["sort_effect_val1"];
- }
-
- $query = "UPDATE char_rank_params SET rank_val1_min = " . $minVal . " where rank_type = 8";
- $dB->query($query);
-
- if ($objUidList == ""){
- $dB->close();
- return array();
- }
-
- $query = "SELECT char_oid, name FROM char_data WHERE char_oid in (" . $objUidList .")";
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $data[$row["char_oid"]]["name"] = $row["name"];
- }
-
- $dB->close();
- return $data;
- }
- function fetchAbilityRank(){
- global $metaData;
-
- $data = array();
- $dB = dbConnect();
-
- $query = "SELECT char_oid,sort_effect_val1, sort_effect_val2 FROM char_stat_sort WHERE sort_type = 9 ORDER BY `sort_effect_val1` DESC , `sort_effect_val2` DESC ";
- $query .= " limit ". $metaData['limit'];
- $result = $dB->query($query);
-
- $objUidList = "";
- $rank = 0;
- $minVal = 0;
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $rank++;
- if($objUidList != ""){
- $objUidList = $objUidList . ",";
- }
- $objUidList = $objUidList . "'" . $row["char_oid"] . "'";
- $data[$row["char_oid"]]['rank'] = $rank;
- $data[$row["char_oid"]]['power'] = $row["sort_effect_val1"];
- $data[$row["char_oid"]]['level'] = $row["sort_effect_val2"];
- $data[$row["char_oid"]]['char_oid'] = $row["char_oid"];
-
- if ($rank == $metaData['limit']) $minVal = $row["sort_effect_val1"];
- }
-
- $query = "UPDATE char_rank_params SET rank_val1_min = " . $minVal . " where rank_type = 9";
- $dB->query($query);
-
- if ($objUidList == ""){
- $dB->close();
- return array();
- }
-
- $query = "SELECT char_oid, name FROM char_data WHERE char_oid in (" . $objUidList .")";
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $data[$row["char_oid"]]["name"] = $row["name"];
- }
-
- $dB->close();
- return $data;
- }
- //飞行宠排行
- function fetchFlypetRank(){
- global $metaData;
-
- $data = array();
- $dB = dbConnect();
-
- $query = "SELECT char_oid, sort_effect_val1, sort_effect_val2 FROM char_stat_sort WHERE sort_type = 10 ORDER BY `sort_effect_val1` DESC , `sort_effect_val2` DESC ";
- $query .= " limit ". $metaData['limit'];
- $result = $dB->query($query);
-
- $objUidList = "";
- $rank = 0;
- $minVal = 0;
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $rank++;
- if($objUidList != ""){
- $objUidList = $objUidList . ",";
- }
- $objUidList = $objUidList . "'" . $row["char_oid"] . "'";
- $data[$row["char_oid"]]['rank'] = $rank;
- $data[$row["char_oid"]]['quality'] = $row["sort_effect_val2"];
- $data[$row["char_oid"]]['char_oid'] = $row["char_oid"];
-
- if ($rank == $metaData['limit']) $minVal = $row["sort_effect_val1"];
- }
-
- $query = "UPDATE char_rank_params SET rank_val1_min = " . $minVal . " where rank_type = 10";
- $dB->query($query);
-
- if ($objUidList == ""){
- $dB->close();
- return array();
- }
-
- $query = "SELECT char_oid, name FROM char_data WHERE char_oid in (" . $objUidList .")";
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $data[$row["char_oid"]]["name"] = $row["name"];
- }
-
- $query = "SELECT char_oid, level FROM char_ride WHERE ride_type = 1 AND char_oid in (" . $objUidList .")";
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $data[$row["char_oid"]]["level"] = $row["level"];
- }
-
- $dB->close();
- return $data;
- }
- //坐骑排行
- function fetchRidepetRank(){
- global $metaData;
-
- $data = array();
- $dB = dbConnect();
-
- $query = "SELECT char_oid, sort_effect_val1, sort_effect_val2 FROM char_stat_sort WHERE sort_type = 11 ORDER BY `sort_effect_val1` DESC , `sort_effect_val2` DESC ";
- $query .= " limit ". $metaData['limit'];
- $result = $dB->query($query);
-
- $objUidList = "";
- $rank = 0;
- $minVal = 0;
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $rank++;
- if($objUidList != ""){
- $objUidList = $objUidList . ",";
- }
- $objUidList = $objUidList . "'" . $row["char_oid"] . "'";
- $data[$row["char_oid"]]['rank'] = $rank;
- $data[$row["char_oid"]]['quality'] = $row["sort_effect_val2"];
- $data[$row["char_oid"]]['char_oid'] = $row["char_oid"];
-
- if ($rank == $metaData['limit']) $minVal = $row["sort_effect_val1"];
- }
-
- $query = "UPDATE char_rank_params SET rank_val1_min = " . $minVal . " where rank_type = 11";
- $dB->query($query);
-
- if ($objUidList == ""){
- $dB->close();
- return array();
- }
-
- $query = "SELECT char_oid, name FROM char_data WHERE char_oid in (" . $objUidList .")";
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $data[$row["char_oid"]]["name"] = $row["name"];
- }
-
- $query = "SELECT char_oid, level FROM char_ride WHERE ride_type = 0 AND char_oid in (" . $objUidList .")";
- $result = $dB->query($query);
- while ($row = $dB->fetchRow($result, MYSQL_ASSOC)) {
- $data[$row["char_oid"]]["level"] = $row["level"];
- }
-
- $dB->close();
- return $data;
- }
- function fetchPageData(&$row, $perKey){
- global $metaData;
- $curTime = time();
- $cacheData = array();
-
- $records = count($row);
- $pageAmount = ceil($records / $metaData['page']);
- $page = 0;
- $idx = 0;
- $cacheKey = $perKey . $page;
- foreach($row as $key => $rankVal){
- if (($idx % $metaData['page'] == 0)){
- $page += 1;
- $cacheKey = $perKey . $page;
- $cacheData[$cacheKey]['attribute']['amount'] = $pageAmount;
- $cacheData[$cacheKey]['attribute']['count'] = $records;
- $cacheData[$cacheKey]['attribute']['page'] = $page;
- $cacheData[$cacheKey]['attribute']['limit'] = $metaData['limit'];
- $cacheData[$cacheKey]['attribute']['date'] = $curTime;
- }
- $cacheData[$cacheKey]['data'][] = $row[$key];
- $idx += 1;
- }
- return $cacheData;
- }
- ?>
复制代码 |