$mode, "class" => self::OVERALL_CHARTS, "type" => $type, ); } break; case self::DAILY_CHARTS : { $sql = "select {$field} from t_rank_battle where mode=:mode and class =:class and type=:type and writetime=:writetime order by value desc,modifytime asc limit {$limit} "; $whereKv = array( "mode" => $mode, "class" => self::DAILY_CHARTS, "type" => $type, "writetime" => myself()->_getNowDaySeconds(), ); } break; case self::WEEKLY_CHARTS : { $sql = "select {$field} from t_rank_battle where mode=:mode and class =:class and type=:type and writetime=:writetime order by value desc,modifytime asc limit {$limit} "; $whereKv = array( "mode" => $mode, "class" => self::WEEKLY_CHARTS, "type" => $type, "writetime" => myself()->_getMondaySeconds(), ); } } // $sql = "select {$field} from t_rank_battle where type=:type order by value desc,modifytime asc limit {$limit} "; // $whereKv = array( // "type" => $type, // ); $rows = myself()->_getSelfMysql()->execQuery($sql,$whereKv); if (!$rows){ $rows = array(); } return $rows; } public static function find($mode,$class,$type){ if (!self::inspectType($type)){ return array(); } $row = array(); switch ($class) { case self::OVERALL_CHARTS : { $row = SqlHelper::ormSelectOne (myself()->_getSelfMysql(), 't_rank_battle', array( 'account_id' => myself()->_getAccountId(), 'type' => $type, 'mode' => $mode, 'class' => $class, ) ); } break; case self::DAILY_CHARTS :{ $row = SqlHelper::ormSelectOne (myself()->_getSelfMysql(), 't_rank_battle', array( 'account_id' => myself()->_getAccountId(), 'type' => $type, 'mode' => $mode, 'class' => $class, "writetime" => myself()->_getNowDaySeconds(), ) ); } break; case self::WEEKLY_CHARTS:{ $row = SqlHelper::ormSelectOne (myself()->_getSelfMysql(), 't_rank_battle', array( 'account_id' => myself()->_getAccountId(), 'type' => $type, 'mode' => $mode, 'class' => $class, "writetime" => myself()->_getMondaySeconds(), ) ); } } return $row ; } public static function upsert($account,$mode,$type,$val){ if (!$account){ return; } SqlHelper::upsert (myself()->_getSelfMysql(), 't_rank_battle', array( 'account_id' => $account, 'mode' => $mode, 'type' => $type, 'class' => self::OVERALL_CHARTS, ), array( 'value' => function () use($val) { return "value + ${val}"; }, 'modifytime' => myself()->_getNowTime(), 'writetime' => myself()->_getNowTime(), ), array( 'account_id' => $account, 'channel' => phpcommon\extractChannel($account), 'class' => self::OVERALL_CHARTS, 'mode' => $mode, 'type' => $type, 'value' => $val, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), 'writetime' => myself()->_getNowTime(), ) ); SqlHelper::upsert (myself()->_getSelfMysql(), 't_rank_battle', array( 'account_id' => $account, 'mode' => $mode, 'type' => $type, 'class' => self::DAILY_CHARTS, 'writetime' => myself()->_getNowDaySeconds(), ), array( 'value' => function () use($val) { return "value + ${val}"; }, 'modifytime' => myself()->_getNowTime(), ), array( 'account_id' => $account, 'channel' => phpcommon\extractChannel($account), 'class' => self::DAILY_CHARTS, 'mode' => $mode, 'type' => $type, 'value' => $val, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), 'writetime' => myself()->_getNowDaySeconds(), ) ); SqlHelper::upsert (myself()->_getSelfMysql(), 't_rank_battle', array( 'account_id' => $account, 'mode' => $mode, 'type' => $type, 'class' => self::WEEKLY_CHARTS, 'writetime' => myself()->_getMondaySeconds(), ), array( 'value' => function () use($val) { return "value + ${val}"; }, 'modifytime' => myself()->_getNowTime(), ), array( 'account_id' => $account, 'channel' => phpcommon\extractChannel($account), 'class' => self::WEEKLY_CHARTS, 'mode' => $mode, 'type' => $type, 'value' => $val, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), 'writetime' => myself()->_getMondaySeconds(), ) ); } }