Add: count record list, search all
This commit is contained in:
@@ -10,31 +10,34 @@ $start_date = $_POST["StartDate"];
|
||||
$end_date = $_POST["EndDate"];
|
||||
$player_name_list = $_POST["PlayerNameList"];
|
||||
$app_id = $_POST["AppID"];
|
||||
$limit_count = $_POST["LimitCount"];
|
||||
|
||||
// echo "start_date : ".$start_date."\n";
|
||||
// echo "end_date : ".$end_date."\n";
|
||||
// echo "player_name_list : ".$player_name_list."\n";
|
||||
// echo "app_id : ".$app_id."\n";
|
||||
// echo "limit_count : ".$limit_count."\n";
|
||||
// echo "\n";
|
||||
|
||||
$replyJSON = null;
|
||||
|
||||
$date_statement = makeDateStatement($start_date, $end_date);
|
||||
$player_name_statement = makePlayerNameStatement($player_name_list);
|
||||
$subject_statement = makeSubjectSentence($app_id);
|
||||
|
||||
// echo "maestro : ".$maestro_id."\n";
|
||||
// echo "date : ".$date_statement."\n";
|
||||
// echo "player_name : ".$player_name_statement."\n";
|
||||
// echo "subject : ".$subject_statement."\n";
|
||||
$where_statement = make_where_statement($date_statement, $player_name_statement, $subject_statement);
|
||||
|
||||
|
||||
$replyJSON = get_player_record_list($maestro_id, $date_statement, $player_name_statement, $subject_statement);
|
||||
$recordCount = get_player_record_count($maestro_id, $where_statement, $limit_count);
|
||||
$recordTotalCount = get_player_record_total_count($maestro_id, $where_statement);
|
||||
$replyJSON = get_player_record_list($maestro_id, $where_statement, $limit_count);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "오늘의 랭킹 기록 없음");
|
||||
$db_conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
set_data("RecordCount", $recordCount);
|
||||
set_data("RecordList", $replyJSON);
|
||||
send_result_success();
|
||||
exit;
|
||||
@@ -55,27 +58,32 @@ function makeSubjectSentence($app_id) {
|
||||
if(is_subject_bundle_item($app_id)) {
|
||||
switch($app_id) {
|
||||
case 1000: // korean practice
|
||||
$subject_statement = $subject_statement." A.AppID < 9";
|
||||
$subject_statement = $subject_statement."A.AppID < 9";
|
||||
break;
|
||||
|
||||
case 1001: // english practice
|
||||
$subject_statement = $subject_statement." 10 < A.AppID AND A.AppID < 19";
|
||||
$subject_statement = $subject_statement."10 < A.AppID AND A.AppID < 19";
|
||||
break;
|
||||
|
||||
case 1002: // korean test
|
||||
$subject_statement = $subject_statement." 20 < A.AppID AND A.AppID < 31";
|
||||
$subject_statement = $subject_statement."20 < A.AppID AND A.AppID < 31";
|
||||
break;
|
||||
|
||||
case 1003: // english test
|
||||
$subject_statement = $subject_statement." 30 < A.AppID AND A.AppID < 41";
|
||||
$subject_statement = $subject_statement."30 < A.AppID AND A.AppID < 41";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$subject_statement = $subject_statement."A.AppID = ".$app_id;
|
||||
}
|
||||
|
||||
$subject_statement = $subject_statement." A.AppID = ".$app_id;
|
||||
return $subject_statement." AND BR.AppID = A.AppID";
|
||||
}
|
||||
|
||||
function makePlayerNameStatement($player_name_list) {
|
||||
$player_name_statement = "BR.PlayerID = P.PlayerID";
|
||||
if($player_name_list.length > 0)
|
||||
$player_name_statement = $player_name_statement." AND P.Name LIKE %".$player_name_list."%";
|
||||
if(strlen($player_name_list) > 0)
|
||||
$player_name_statement = $player_name_statement." AND P.Name LIKE '%".$player_name_list."%'";
|
||||
|
||||
return $player_name_statement;
|
||||
}
|
||||
@@ -88,28 +96,85 @@ function is_subject_bundle_item($app_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_player_record_list($maestro_id, $date_statement, $player_name_statement, $subject_statement) {
|
||||
global $db_conn;
|
||||
|
||||
function make_where_statement($date_statement, $player_name_statement, $subject_statement) {
|
||||
// add date condition
|
||||
$where_statement = $date_statement;
|
||||
if(strlen($where_statement) > 0 and strlen($player_name_statement) > 0)
|
||||
$where_statement = $where_statement." AND ";
|
||||
|
||||
// add player name condition
|
||||
$where_statement = $where_statement.$player_name_statement;
|
||||
|
||||
// add subject condition
|
||||
if(strlen($where_statement) > 0 and strlen($subject_statement) > 0)
|
||||
$where_statement = $where_statement." AND ";
|
||||
$where_statement = $where_statement.$subject_statement;
|
||||
|
||||
// echo $where_statement."\n\n";
|
||||
return $where_statement;
|
||||
}
|
||||
|
||||
function get_player_record_count($maestro_id, $where_statement, $limit_count) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT COUNT(*)
|
||||
FROM best_record BR, player P, App A
|
||||
WHERE BR.MaestroID = ? AND ".$where_statement."
|
||||
";
|
||||
|
||||
if($limit_count > 0)
|
||||
$query = $query." LIMIT ".$limit_count;
|
||||
|
||||
// echo $query;
|
||||
// return;
|
||||
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param("i", $maestro_id);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($record_count);
|
||||
$stmt->fetch();
|
||||
$stmt->close();
|
||||
|
||||
return $record_count;
|
||||
}
|
||||
|
||||
function get_player_record_total_count($maestro_id, $where_statement) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT COUNT(*)
|
||||
FROM best_record BR, player P, App A
|
||||
WHERE BR.MaestroID = ? AND ".$where_statement."
|
||||
";
|
||||
|
||||
// echo $query;
|
||||
// return;
|
||||
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param("i", $maestro_id);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($record_count);
|
||||
$stmt->fetch();
|
||||
$stmt->close();
|
||||
|
||||
return $record_count;
|
||||
}
|
||||
|
||||
function get_player_record_list($maestro_id, $where_statement, $limit_count) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT DATE(BR.RecordDateTime) AS Date, TIME(BR.RecordDateTime) AS Time,
|
||||
P.Name AS Name, A.KoreanName AS Subject, BR.BestRecord AS Record
|
||||
FROM best_record BR, player P, App A
|
||||
WHERE BR.MaestroID = ? AND ".$where_statement."
|
||||
ORDER BY BR.RecordDateTime ASC;
|
||||
ORDER BY BR.RecordDateTime ASC
|
||||
";
|
||||
|
||||
if($limit_count > 0)
|
||||
$query = $query." LIMIT ".$limit_count;
|
||||
|
||||
// echo $query;
|
||||
// return;
|
||||
|
||||
@@ -127,7 +192,7 @@ function get_player_record_list($maestro_id, $date_statement, $player_name_state
|
||||
$record_date['Record'] = $record;
|
||||
array_push($record_array, $record_date);
|
||||
}
|
||||
$return_array['RecordList'] = $record_array;
|
||||
// $return_array['RecordList'] = $record_array;
|
||||
|
||||
// return $return_array;
|
||||
return $record_array;
|
||||
|
||||
Reference in New Issue
Block a user