diff --git a/third_party/phpcommon b/third_party/phpcommon index 4fa9d00..914355e 160000 --- a/third_party/phpcommon +++ b/third_party/phpcommon @@ -1 +1 @@ -Subproject commit 4fa9d00842f4fd2fb2c0b3c82bfdaa4f7ac6a602 +Subproject commit 914355e0f3d6ca491b299489adf475f93d211389 diff --git a/webapp/controller/HangController.class.php b/webapp/controller/HangController.class.php index 22ef12f..e2e0c63 100644 --- a/webapp/controller/HangController.class.php +++ b/webapp/controller/HangController.class.php @@ -54,11 +54,11 @@ class HangController{ ':accountid' => $account_id )); $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num ' . - ' WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - ':coin_num' => $num + $row['coin_num'] - )); + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':coin_num' => $num + $row['coin_num'] + )); } echo json_encode(array( 'errcode' => 0, diff --git a/webapp/controller/RankController.class.php b/webapp/controller/RankController.class.php index b862047..b742340 100644 --- a/webapp/controller/RankController.class.php +++ b/webapp/controller/RankController.class.php @@ -44,10 +44,10 @@ class RankController{ } array_push($kill_list, array( 'account_id' => $row['accountid'], - 'kill' => $row['kills'] / $row['game_times'], - 'alive'=> $row['alive_time'] / $row['game_times'], - 'harm' => $row['harm'] / $row['game_times'], - 'win_rate' => $row['win_times'] / $row['game_times'], + 'kill' => phpcommon\safeDiv($row['kills'], $row['game_times']), + 'alive'=> phpcommon\safeDiv($row['alive_time'], $row['game_times']), + 'harm' => phpcommon\safeDiv($row['harm'], $row['game_times']), + 'win_rate' => phpcommon\safeDiv($row['win_times'], $row['game_times']), 'win_game' => $row['win_times'] )); $i++; @@ -64,10 +64,10 @@ class RankController{ } array_push($alive_list, array( 'account_id' => $row['accountid'], - 'kill' => $row['kills'] / $row['game_times'], - 'alive'=> $row['alive_time'] / $row['game_times'], - 'harm' => $row['harm'] / $row['game_times'], - 'win_rate' => $row['win_times'] / $row['game_times'], + 'kill' => phpcommon\safeDiv($row['kills'], $row['game_times']), + 'alive'=> phpcommon\safeDiv($row['alive_time'], $row['game_times']), + 'harm' => phpcommon\safeDiv($row['harm'], $row['game_times']), + 'win_rate' => phpcommon\safeDiv($row['win_times'], $row['game_times']), 'win_game' => $row['win_times'] )); $i++; @@ -84,10 +84,10 @@ class RankController{ } array_push($harm_list, array( 'account_id' => $row['accountid'], - 'kill' => $row['kills'] / $row['game_times'], - 'alive'=> $row['alive_time'] / $row['game_times'], - 'harm' => $row['harm'] / $row['game_times'], - 'win_rate' => $row['win_times'] / $row['game_times'], + 'kill' => phpcommon\safeDiv($row['kills'], $row['game_times']), + 'alive'=> phpcommon\safeDiv($row['alive_time'], $row['game_times']), + 'harm' => phpcommon\safeDiv($row['harm'], $row['game_times']), + 'win_rate' => phpcommon\safeDiv($row['win_times'], $row['game_times']), 'win_game' => $row['win_times'] )); $i++; @@ -104,10 +104,10 @@ class RankController{ } array_push($rate_list, array( 'account_id' => $row['accountid'], - 'kill' => $row['kills'] / $row['game_times'], - 'alive'=> $row['alive_time'] / $row['game_times'], - 'harm' => $row['harm'] / $row['game_times'], - 'win_rate' => $row['win_times'] / $row['game_times'], + 'kill' => phpcommon\safeDiv($row['kills'], $row['game_times']), + 'alive'=> phpcommon\safeDiv($row['alive_time'], $row['game_times']), + 'harm' => phpcommon\safeDiv($row['harm'], $row['game_times']), + 'win_rate' => phpcommon\safeDiv($row['win_times'], $row['game_times']), 'win_game' => $row['win_times'] )); $i++; @@ -124,10 +124,10 @@ class RankController{ } array_push($win_list, array( 'account_id' => $row['accountid'], - 'kill' => $row['kills'] / $row['game_times'], - 'alive'=> $row['alive_time'] / $row['game_times'], - 'harm' => $row['harm'] / $row['game_times'], - 'win_rate' => $row['win_times'] / $row['game_times'], + 'kill' => phpcommon\safeDiv($row['kills'], $row['game_times']), + 'alive'=> phpcommon\safeDiv($row['alive_time'], $row['game_times']), + 'harm' => phpcommon\safeDiv($row['harm'], $row['game_times']), + 'win_rate' => phpcommon\safeDiv($row['win_times'], $row['game_times']), 'win_game' => $row['win_times'] ));