_getSelfMysql(), 't_battle_history', $data ); } public static function getMyBattleHistoryByMode($mode) { if ($mode == 1) { $row1 = SqlHelper::ormSelect( myself()->_getSelfMysql(), 't_battle_history', array( 'account_id' => myself()->_getAccountId(), 'match_mode' => 0, ) ); $row2 = SqlHelper::ormSelect( myself()->_getSelfMysql(), 't_battle_history', array( 'account_id' => myself()->_getAccountId(), 'match_mode' => 1, ) ); $row = array_merge($row1,$row2); return $row; }elseif($mode == 2){ $row = SqlHelper::ormSelect( myself()->_getSelfMysql(), 't_battle_history', array( 'account_id' => myself()->_getAccountId(), 'match_mode' => 2, ) ); return $row; }else{ return array(); } } public static function toDto($row){ if ($row['hero_id']){ $heroDb = Hero::findByAccountId($row['account_id'],$row['hero_id']); $row['hero_id'] =$heroDb ? $heroDb['hero_id'] : 0; } if ($row['weapon1']){ $weaponDb1 = Gun::findByAccountId($row['account_id'],$row['weapon1']); $row['weapon1'] =$weaponDb1 ? $weaponDb1['gun_id'] : 0; } if ($row['weapon2']){ $weaponDb2 = Gun::findByAccountId($row['account_id'],$row['weapon2']); $row['weapon2'] = $weaponDb2 ? $weaponDb2['gun_id'] : 0; } return $row; } public static function orderBy($data,$order){ $len = count($data); if ($len<=1){ return $data; } if ($order == 'desc'){ for ($i = 0; $i < $len - 1; $i++) { for ($j = $i + 1; $j < $len; $j++) { if ($data[$i]['idx'] < $data[$j]['idx']) { $tmp = $data[$i]; $data[$i] = $data[$j]; $data[$j] = $tmp; } } } }else{ for ($i = 0; $i < $len - 1; $i++) { for ($j = $i + 1; $j < $len; $j++) { if ($data[$i]['idx'] > $data[$j]['idx']) { $tmp = $data[$i]; $data[$i] = $data[$j]; $data[$j] = $tmp; } } } } return $data; } public static function findByAccount($account,$battleUid){ return SqlHelper::ormSelectOne( myself()->_getSelfMysql(), 't_battle_history', array( 'account_id' => $account, 'battle_uniid' => $battleUid, ) ); } public static function updateField($account,$battleUid,$field){ return SqlHelper::update( myself()->_getSelfMysql(), 't_battle_history', array( 'account_id' => $account, 'battle_uniid' => $battleUid, ), $field ); } }