game2006api/webapp/models/Circuit.php
hujiabin 976d490bd2 1
2024-09-19 15:59:34 +08:00

68 lines
1.9 KiB
PHP

<?php
namespace models;
use mt;
use phpcommon\SqlHelper;
class Circuit extends BaseModel
{
public static function updateScore($season,$score){
SqlHelper::upsert(
myself()->_getSelfMysql(),
't_circuit_battle',
array(
'account_id' => myself()->_getAccountId(),
'season' => $season
),
array(
'cumulative_score' => $score,
'modifytime' => myself()->_getNowTime()
),
array(
'account_id' => myself()->_getAccountId(),
'season' => $season,
'cumulative_score' => $score,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
}
public static function getMyScore($season){
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_circuit_battle',
array(
'account_id' => myself()->_getAccountId(),
'season' => $season
)
);
return $row ? $row['cumulative_score'] : 0;
}
public static function getRankingList($season){
$sql = "select * from t_circuit_battle where season=:season order by cumulative_score desc,modifytime asc";
$whereKv = array(
"season" => $season,
);
$rows = myself()->_getSelfMysql()->execQuery($sql,$whereKv);
if (!$rows){
$rows = array();
}
return $rows;
}
public static function getCurrentMyScore(){
$circuitMeta = myself()->_callMtStatic('CircuitTime', 'getCurrentCircuit');
if (empty($circuitMeta)) {
return 0;
}
return self::getMyScore($circuitMeta['circuit_season']);
}
}