애플리케이션(PHP, 화면) 개선
This commit is contained in:
1 parent
629c8ff83f
commit
99631c1061
20 files changed
+695
-515
No files matched your search
@@ -73,9 +73,9 @@ class MenuCollection extends DBMethodContainer
|
||||
return $this->getTypingAppList($maestroID, $playerID, $appGroup, $language);
|
||||
|
||||
case 2:
|
||||
if($writingCollection === null)
|
||||
$writingCollection = new WritingCollection($this->mysqli);
|
||||
$systemWritingList = $writingCollection->getSystemList($language);
|
||||
if($this->writingCollection === null)
|
||||
$this->writingCollection = new WritingCollection($this->mysqli);
|
||||
$systemWritingList = $this->writingCollection->getSystemList($language);
|
||||
return $systemWritingList;
|
||||
|
||||
case 4: // mouse play
|
||||
@@ -142,9 +142,9 @@ class MenuCollection extends DBMethodContainer
|
||||
return $this->getTypingActiveAppList($maestroID, $playerID, $appGroup, $language);
|
||||
|
||||
case 2:
|
||||
if($writingCollection === null)
|
||||
$writingCollection = new WritingCollection($this->mysqli);
|
||||
$activeSystemWritingList = $writingCollection->getActiveSystemList($maestroID, $language);
|
||||
if($this->writingCollection === null)
|
||||
$this->writingCollection = new WritingCollection($this->mysqli);
|
||||
$activeSystemWritingList = $this->writingCollection->getActiveSystemList($maestroID, $language);
|
||||
return $activeSystemWritingList;
|
||||
|
||||
case 4: // mouse play
|
||||
@@ -199,7 +199,7 @@ class MenuCollection extends DBMethodContainer
|
||||
|
||||
|
||||
// highest record list
|
||||
public function getHighestRecordList($maestroID, $playerID, $appList)
|
||||
public function getHighestRecordList($maestroID, $playerID, $appGroup, $appList)
|
||||
{
|
||||
switch($appGroup) {
|
||||
case 0: // typing practice
|
||||
@@ -215,15 +215,20 @@ class MenuCollection extends DBMethodContainer
|
||||
|
||||
public function getWritingHighestRecordList($maestroID, $playerID, $appList)
|
||||
{
|
||||
if($writingCollection === null)
|
||||
$writingCollection = new WritingCollection($this->mysqli);
|
||||
if($this->writingCollection === null)
|
||||
$this->writingCollection = new WritingCollection($this->mysqli);
|
||||
|
||||
$writingIDs = array();
|
||||
foreach($appList as $app)
|
||||
$writingIDs[] = $app["writingID"];
|
||||
|
||||
$recordMap = $this->writingCollection->getWritingHighestRecordMap($maestroID, $playerID, $writingIDs);
|
||||
|
||||
$highestRecordArray = array();
|
||||
$count = count($appList);
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
$writingID = $appList[$i]["writingID"];
|
||||
foreach($writingIDs as $writingID) {
|
||||
$highestRecord = array();
|
||||
$highestRecord["writingID"] = $writingID;
|
||||
$highestRecord["highestRecord"] = $writingCollection->getWritingHighestRecord($maestroID, $playerID, $writingID);
|
||||
$highestRecord["highestRecord"] = isset($recordMap[$writingID]) ? $recordMap[$writingID] : 0;
|
||||
array_push($highestRecordArray, $highestRecord);
|
||||
}
|
||||
|
||||
@@ -232,35 +237,46 @@ class MenuCollection extends DBMethodContainer
|
||||
|
||||
public function getTypingHighestRecordList($maestroID, $playerID, $appList)
|
||||
{
|
||||
$highestRecordArray = array();
|
||||
$count = count($appList);
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
$appID = $appList[$i]["appID"];
|
||||
$highestRecord["appID"] = $appID;
|
||||
$highestRecord["highestRecord"] = $this->getTypingHighestRecord($maestroID, $playerID, $appID);
|
||||
array_push($highestRecordArray, $highestRecord);
|
||||
$appIDs = array();
|
||||
foreach($appList as $app)
|
||||
$appIDs[] = $app["appID"];
|
||||
|
||||
$recordMap = $this->getTypingHighestRecordMap($maestroID, $playerID, $appIDs);
|
||||
|
||||
$highestRecordArray = array();
|
||||
foreach($appIDs as $appID) {
|
||||
$highestRecord = array();
|
||||
$highestRecord["appID"] = $appID;
|
||||
$highestRecord["highestRecord"] = isset($recordMap[$appID]) ? $recordMap[$appID] : 0;
|
||||
array_push($highestRecordArray, $highestRecord);
|
||||
}
|
||||
|
||||
return $highestRecordArray;
|
||||
}
|
||||
|
||||
public function getTypingHighestRecord($maestroID, $playerID, $appID)
|
||||
private function getTypingHighestRecordMap($maestroID, $playerID, $appIDs)
|
||||
{
|
||||
$recordMap = array();
|
||||
if(count($appIDs) === 0)
|
||||
return $recordMap;
|
||||
|
||||
// MAX + GROUP BY: UNIQUE 키가 없는 DB에서도 앱당 1행. COALESCE를 쓰면 FLOAT가 DOUBLE로 바뀌어 소수점이 길어짐
|
||||
$placeholders = implode(",", array_fill(0, count($appIDs), "?"));
|
||||
$query = "
|
||||
SELECT HighestRecord
|
||||
SELECT AppID, MAX(HighestRecord)
|
||||
FROM app_highest_record
|
||||
WHERE MaestroID=? AND PlayerID=? AND AppID=?";
|
||||
WHERE MaestroID=? AND PlayerID=? AND AppID IN (" . $placeholders . ")
|
||||
GROUP BY AppID";
|
||||
$params = array_merge(array($maestroID, $playerID), $appIDs);
|
||||
$stmt = $this->mysqli->prepare($query);
|
||||
$stmt->bind_param("iii", $maestroID, $playerID, $appID);
|
||||
$stmt->bind_param(str_repeat("i", count($params)), ...$params);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($highestRecord);
|
||||
$returnValue = $stmt->fetch();
|
||||
$stmt->bind_result($appID, $highestRecord);
|
||||
while($stmt->fetch())
|
||||
$recordMap[$appID] = $highestRecord;
|
||||
$stmt->close();
|
||||
|
||||
if($returnValue === NULL || $returnValue === FALSE)
|
||||
return 0;
|
||||
|
||||
return $highestRecord;
|
||||
return $recordMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ class TypingExamCollection extends DBMethodContainer
|
||||
FROM typing_exam_highest_record
|
||||
WHERE MaestroID = ? AND PlayerID = ?";
|
||||
$stmt = $this->mysqli->prepare($query);
|
||||
$stmt->bind_param("iii", $maestroID, $playerID);
|
||||
$stmt->bind_param("ii", $maestroID, $playerID);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($typingExamHighestRecordID, $writingID, $highestRecord);
|
||||
|
||||
|
||||
@@ -66,23 +66,29 @@ class WritingCollection extends DBMethodContainer
|
||||
return $writingList;
|
||||
}
|
||||
|
||||
public function getWritingHighestRecord($maestroID, $playerID, $writingID)
|
||||
public function getWritingHighestRecordMap($maestroID, $playerID, $writingIDs)
|
||||
{
|
||||
$recordMap = array();
|
||||
if(count($writingIDs) === 0)
|
||||
return $recordMap;
|
||||
|
||||
// MAX + GROUP BY: UNIQUE 키가 없는 DB에서도 글당 1행. COALESCE를 쓰면 FLOAT가 DOUBLE로 바뀌어 소수점이 길어짐
|
||||
$placeholders = implode(",", array_fill(0, count($writingIDs), "?"));
|
||||
$query = "
|
||||
SELECT WritingID, HighestRecord
|
||||
SELECT WritingID, MAX(HighestRecord)
|
||||
FROM typing_exam_highest_record
|
||||
WHERE MaestroID=? AND PlayerID=? AND WritingID=?";
|
||||
WHERE MaestroID=? AND PlayerID=? AND WritingID IN (" . $placeholders . ")
|
||||
GROUP BY WritingID";
|
||||
$params = array_merge(array($maestroID, $playerID), $writingIDs);
|
||||
$stmt = $this->mysqli->prepare($query);
|
||||
$stmt->bind_param("iii", $maestroID, $playerID, $writingID);
|
||||
$stmt->bind_param(str_repeat("i", count($params)), ...$params);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($writingID, $highestRecord);
|
||||
$returnValue = $stmt->fetch();
|
||||
while($stmt->fetch())
|
||||
$recordMap[$writingID] = $highestRecord;
|
||||
$stmt->close();
|
||||
|
||||
if($returnValue === NULL || $returnValue === FALSE)
|
||||
return 0;
|
||||
|
||||
return $highestRecord;
|
||||
return $recordMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ $activeAppList = $menuCollection->getActiveAppList($maestroID, $playerID, $appGr
|
||||
if($appGroup === "2") // typing exam
|
||||
$highestRecordList = $menuCollection->getWritingHighestRecordList($maestroID, $playerID, $appList);
|
||||
else
|
||||
$highestRecordList = $menuCollection->getHighestRecordList($maestroID, $playerID, $appList);
|
||||
$highestRecordList = $menuCollection->getHighestRecordList($maestroID, $playerID, $appGroup, $appList);
|
||||
// $highestRecordList = $menuCollection->getHighestRecordList($maestroID, $playerID, $appList);
|
||||
|
||||
|
||||
|
||||
@@ -8,11 +8,6 @@ include "./../setup/connect_db.php";
|
||||
|
||||
$replyJSON = array();
|
||||
$replyJSON["HowToPlay"] = get_how_to_play($app_id);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "히스토리 기록 없음");
|
||||
$db_conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
$db_conn->close();
|
||||
|
||||
@@ -13,13 +13,6 @@ $typingActiveAppList = get_active_typing_app_list($maestro_id);
|
||||
$typingPracticeAppCount = get_typing_practice_app_count($maestro_id);
|
||||
$typingTestAppCount = get_typing_test_app_count($maestro_id);
|
||||
|
||||
if($replyJSON.length === 0) {
|
||||
set_error_code("no_app_list");
|
||||
set_error_message("앱 목록을 가져오지 못했습니다.");
|
||||
send_result_fail();
|
||||
exit;
|
||||
}
|
||||
|
||||
set_data("MouseAppList", $mouseAppList);
|
||||
set_data("TypingAppList", $typingAppList);
|
||||
set_data("MouseActiveAppList", $mouseActiveAppList);
|
||||
|
||||
@@ -8,11 +8,6 @@ $maestroID = $_POST["maestro_id"];
|
||||
|
||||
|
||||
$mouse_app_list = get_mouse_app_list();
|
||||
if($mouse_app_list.length === 0) {
|
||||
set_error_message("등록된 마우스 앱 없음");
|
||||
send_result_fail();
|
||||
exit;
|
||||
}
|
||||
|
||||
$activated_mouse_app_list = get_activated_mouse_app_list($maestroID);
|
||||
|
||||
|
||||
@@ -8,11 +8,6 @@ $maestroID = $_POST["maestro_id"];
|
||||
|
||||
|
||||
$typing_app_list = get_typing_app_list();
|
||||
if($typing_app_list.length === 0) {
|
||||
set_error_message("등록된 타자 앱 없음");
|
||||
send_result_fail();
|
||||
exit;
|
||||
}
|
||||
|
||||
$activated_typing_app_list = get_activated_typing_app_list($maestroID);
|
||||
|
||||
|
||||
@@ -11,11 +11,6 @@ $endNo = $_POST["end_no"];
|
||||
|
||||
|
||||
$playerList = get_player_list_page($maestroID, $playerName, $startNo, $endNo);
|
||||
if($playerList.length === 0) {
|
||||
set_error_message("해당 이름으로 등록된 학생 없음");
|
||||
send_result_fail();
|
||||
exit;
|
||||
}
|
||||
|
||||
set_data("playerList", $playerList);
|
||||
send_result_success();
|
||||
|
||||
@@ -11,11 +11,6 @@ include "./../lib/util_app.php";
|
||||
|
||||
|
||||
$replyJSON = get_history_record($maestro_id, $app_id, $player_id, $date);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "히스토리 기록 없음");
|
||||
$db_conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
$db_conn->close();
|
||||
@@ -52,7 +47,6 @@ function get_history_record($maestro_id, $app_id, $player_id, $date) {
|
||||
$history_record['HighScore'] = $score;
|
||||
$history_record['AppName'] = $app_name;
|
||||
array_push($history_record_array, $history_record);
|
||||
array_push($return_array, $history_record);
|
||||
}
|
||||
$return_array['history'] = $history_record_array;
|
||||
|
||||
|
||||
@@ -11,11 +11,6 @@ include "./../lib/util_app.php";
|
||||
|
||||
|
||||
$replyJSON = get_ranking_record_day($maestro_id, $date, $app_id);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "오늘의 랭킹 기록 없음");
|
||||
$db_conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
$db_conn->close();
|
||||
|
||||
@@ -11,11 +11,6 @@ include "./../lib/util_app.php";
|
||||
|
||||
|
||||
$replyJSON = get_ranking_record_hour($maestro_id, $date, $time, $app_id);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "수업시간 랭킹 기록 없음");
|
||||
$db_conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
$db_conn->close();
|
||||
|
||||
@@ -11,11 +11,6 @@ include "./../lib/util_app.php";
|
||||
|
||||
|
||||
$replyJSON = get_ranking_record_month($maestro_id, $date, $time, $app_id);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "이달의 랭킹 기록 없음");
|
||||
$db_conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
$db_conn->close();
|
||||
|
||||
@@ -11,11 +11,6 @@ include "./../lib/app_highest_record.php";
|
||||
|
||||
$replyJSON = array();
|
||||
$replyJSON["AppHighestRecord"] = get_app_highest_record($maestro_id, $app_id, $player_id);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "히스토리 기록 없음");
|
||||
$db_conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
$db_conn->close();
|
||||
|
||||
@@ -5,36 +5,15 @@ include "./../lib/send_reply_json.php";
|
||||
include "./../lib/maestro_account_info.php";
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
$maestro_id = $_POST["MaestroID"];
|
||||
$maestro_id = (int)$_POST["MaestroID"];
|
||||
$start_date = $_POST["StartDate"];
|
||||
$end_date = $_POST["EndDate"];
|
||||
$player_name_list = $_POST["PlayerNameList"];
|
||||
$app_id = $_POST["AppID"];
|
||||
$limit_count = $_POST["LimitCount"];
|
||||
$player_name = trim($_POST["PlayerNameList"]);
|
||||
$app_id = (int)$_POST["AppID"];
|
||||
$limit_count = (int)$_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";
|
||||
|
||||
$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);
|
||||
|
||||
$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;
|
||||
}
|
||||
$recordTotalCount = get_player_record_total_count($maestro_id, $start_date, $end_date, $player_name, $app_id);
|
||||
$replyJSON = get_player_record_list($maestro_id, $start_date, $end_date, $player_name, $app_id, $limit_count);
|
||||
|
||||
set_data("RecordTotalCount", $recordTotalCount);
|
||||
set_data("RecordList", $replyJSON);
|
||||
@@ -42,117 +21,52 @@ send_result_success();
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
function makeDateStatement($start_date, $end_date) {
|
||||
return " '".$start_date."' <= BR.RecordDateTime AND BR.RecordDateTime <= DATE_ADD('".$end_date."', INTERVAL 1 DAY)";
|
||||
// return " '2017-01-01' < BR.RecordDateTime AND BR.RecordDateTime < '".$end_date."'";
|
||||
function get_subject_app_range($app_id) {
|
||||
switch ($app_id) {
|
||||
case 0: return null;
|
||||
case 1000: return array(1, 8);
|
||||
case 1001: return array(11, 18);
|
||||
case 1002: return array(21, 30);
|
||||
case 1003: return array(31, 40);
|
||||
default: return array($app_id, $app_id);
|
||||
}
|
||||
}
|
||||
|
||||
function makeSubjectSentence($app_id) {
|
||||
if($app_id == 0)
|
||||
return "";
|
||||
|
||||
$subject_statement = "";
|
||||
if(is_subject_bundle_item($app_id)) {
|
||||
switch($app_id) {
|
||||
case 1000: // korean practice
|
||||
$subject_statement = $subject_statement."A.AppID < 9";
|
||||
break;
|
||||
function get_player_record_total_count($maestro_id, $start_date, $end_date, $player_name, $app_id) {
|
||||
global $db_conn;
|
||||
|
||||
case 1001: // english practice
|
||||
$subject_statement = $subject_statement."10 < A.AppID AND A.AppID < 19";
|
||||
break;
|
||||
$where = array(
|
||||
"BR.MaestroID = ?",
|
||||
"BR.RecordDateTime >= DATE(?)",
|
||||
"BR.RecordDateTime < DATE(?) + INTERVAL 1 DAY",
|
||||
"BR.PlayerID = P.PlayerID",
|
||||
"BR.AppID = A.AppID",
|
||||
);
|
||||
$types = "iss";
|
||||
$params = array($maestro_id, $start_date, $end_date);
|
||||
|
||||
case 1002: // korean test
|
||||
$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";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$subject_statement = $subject_statement."A.AppID = ".$app_id;
|
||||
if (strlen($player_name) > 0) {
|
||||
$where[] = "P.Name LIKE ?";
|
||||
$types .= "s";
|
||||
$params[] = "%" . $player_name . "%";
|
||||
}
|
||||
|
||||
return $subject_statement." AND BR.AppID = A.AppID";
|
||||
}
|
||||
|
||||
function makePlayerNameStatement($player_name_list) {
|
||||
$player_name_statement = "BR.PlayerID = P.PlayerID";
|
||||
if(strlen($player_name_list) > 0)
|
||||
$player_name_statement = $player_name_statement." AND P.Name LIKE '%".$player_name_list."%'";
|
||||
|
||||
return $player_name_statement;
|
||||
}
|
||||
|
||||
|
||||
function is_subject_bundle_item($app_id) {
|
||||
if($app_id >= 1000)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
return $where_statement;
|
||||
}
|
||||
|
||||
/*
|
||||
function get_player_record_count($maestro_id, $where_statement, $limit_count) {
|
||||
global $db_conn;
|
||||
$range = get_subject_app_range($app_id);
|
||||
if ($range !== null) {
|
||||
$where[] = "BR.AppID BETWEEN ? AND ?";
|
||||
$types .= "ii";
|
||||
$params[] = $range[0];
|
||||
$params[] = $range[1];
|
||||
}
|
||||
|
||||
$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;
|
||||
WHERE " . implode(" AND ", $where);
|
||||
|
||||
$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->bind_param($types, ...$params);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($record_count);
|
||||
$stmt->fetch();
|
||||
@@ -161,38 +75,63 @@ function get_player_record_total_count($maestro_id, $where_statement) {
|
||||
return $record_count;
|
||||
}
|
||||
|
||||
function get_player_record_list($maestro_id, $where_statement, $limit_count) {
|
||||
|
||||
function get_player_record_list($maestro_id, $start_date, $end_date, $player_name, $app_id, $limit_count) {
|
||||
global $db_conn;
|
||||
|
||||
$where = array(
|
||||
"BR.MaestroID = ?",
|
||||
"BR.RecordDateTime >= DATE(?)",
|
||||
"BR.RecordDateTime < DATE(?) + INTERVAL 1 DAY",
|
||||
"BR.PlayerID = P.PlayerID",
|
||||
"BR.AppID = A.AppID",
|
||||
);
|
||||
$types = "iss";
|
||||
$params = array($maestro_id, $start_date, $end_date);
|
||||
|
||||
if (strlen($player_name) > 0) {
|
||||
$where[] = "P.Name LIKE ?";
|
||||
$types .= "s";
|
||||
$params[] = "%" . $player_name . "%";
|
||||
}
|
||||
|
||||
$range = get_subject_app_range($app_id);
|
||||
if ($range !== null) {
|
||||
$where[] = "BR.AppID BETWEEN ? AND ?";
|
||||
$types .= "ii";
|
||||
$params[] = $range[0];
|
||||
$params[] = $range[1];
|
||||
}
|
||||
|
||||
$query = "
|
||||
SELECT BR.BestRecordID AS Id, DATE(BR.RecordDateTime) AS Date, TIME(BR.RecordDateTime) AS Time,
|
||||
P.Name AS Name, A.KoreanName AS Subject, BR.BestRecord AS Record
|
||||
SELECT BR.BestRecordID, DATE(BR.RecordDateTime), TIME(BR.RecordDateTime),
|
||||
P.Name, A.KoreanName, BR.BestRecord
|
||||
FROM best_record BR, player P, app A
|
||||
WHERE BR.MaestroID = ? AND ".$where_statement."
|
||||
ORDER BY BR.RecordDateTime DESC
|
||||
";
|
||||
WHERE " . implode(" AND ", $where) . "
|
||||
ORDER BY BR.RecordDateTime DESC";
|
||||
|
||||
if($limit_count > 0)
|
||||
$query = $query." LIMIT ".$limit_count;
|
||||
|
||||
// echo $query;
|
||||
// return;
|
||||
if ($limit_count > 0) {
|
||||
$query .= " LIMIT ?";
|
||||
$types .= "i";
|
||||
$params[] = $limit_count;
|
||||
}
|
||||
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('i', $maestro_id);
|
||||
$stmt->bind_param($types, ...$params);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($id, $date, $time, $player_name, $subject, $record);
|
||||
$stmt->bind_result($id, $date, $time, $player_name_result, $subject, $record);
|
||||
|
||||
$record_array = array();
|
||||
while($stmt->fetch()) {
|
||||
$record_date['Id'] = $id;
|
||||
$record_date['Date'] = $date;
|
||||
$record_date['Time'] = $time;
|
||||
$record_date['PlayerName'] = $player_name;
|
||||
$record_date['Subject'] = $subject;
|
||||
$record_date['Record'] = $record;
|
||||
array_push($record_array, $record_date);
|
||||
$record_date['Id'] = $id;
|
||||
$record_date['Date'] = $date;
|
||||
$record_date['Time'] = $time;
|
||||
$record_date['PlayerName'] = $player_name_result;
|
||||
$record_date['Subject'] = $subject;
|
||||
$record_date['Record'] = $record;
|
||||
array_push($record_array, $record_date);
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
return $record_array;
|
||||
}
|
||||
|
||||
@@ -5,36 +5,15 @@ include "./../lib/send_reply_json.php";
|
||||
include "./../lib/maestro_account_info.php";
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
$maestro_id = $_POST["MaestroID"];
|
||||
$maestro_id = (int)$_POST["MaestroID"];
|
||||
$start_date = $_POST["StartDate"];
|
||||
$end_date = $_POST["EndDate"];
|
||||
$player_name_list = $_POST["PlayerNameList"];
|
||||
$app_id = $_POST["AppID"];
|
||||
$limit_count = $_POST["LimitCount"];
|
||||
$player_name = trim($_POST["PlayerNameList"]);
|
||||
$app_id = (int)$_POST["AppID"];
|
||||
$limit_count = (int)$_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";
|
||||
|
||||
$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);
|
||||
|
||||
$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;
|
||||
}
|
||||
$recordTotalCount = get_player_record_total_count($maestro_id, $start_date, $end_date, $player_name, $app_id);
|
||||
$replyJSON = get_player_record_list($maestro_id, $start_date, $end_date, $player_name, $app_id, $limit_count);
|
||||
|
||||
set_data("RecordTotalCount", $recordTotalCount);
|
||||
set_data("RecordList", $replyJSON);
|
||||
@@ -42,119 +21,52 @@ send_result_success();
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
function makeDateStatement($start_date, $end_date) {
|
||||
return " '".$start_date."' < LS.ScoreDateTime AND LS.ScoreDateTime < '".$end_date."'";
|
||||
// return " '2017-01-01' < LS.ScoreDateTime AND LS.ScoreDateTime < '".$end_date."'";
|
||||
function get_subject_app_range($app_id) {
|
||||
switch ($app_id) {
|
||||
case 0: return null;
|
||||
case 1000: return array(1, 8);
|
||||
case 1001: return array(11, 18);
|
||||
case 1002: return array(21, 30);
|
||||
case 1003: return array(31, 40);
|
||||
case 3000: return null;
|
||||
default: return array($app_id, $app_id);
|
||||
}
|
||||
}
|
||||
|
||||
function makeSubjectSentence($app_id) {
|
||||
if($app_id == 0)
|
||||
return "";
|
||||
else if($app_id == 3000)
|
||||
return "";
|
||||
|
||||
$subject_statement = "";
|
||||
if(is_subject_bundle_item($app_id)) {
|
||||
switch($app_id) {
|
||||
case 1000: // korean practice
|
||||
$subject_statement = $subject_statement."A.AppID < 9";
|
||||
break;
|
||||
function get_player_record_total_count($maestro_id, $start_date, $end_date, $player_name, $app_id) {
|
||||
global $db_conn;
|
||||
|
||||
case 1001: // english practice
|
||||
$subject_statement = $subject_statement."10 < A.AppID AND A.AppID < 19";
|
||||
break;
|
||||
$where = array(
|
||||
"LS.MaestroID = ?",
|
||||
"LS.ScoreDateTime >= DATE(?)",
|
||||
"LS.ScoreDateTime < DATE(?) + INTERVAL 1 DAY",
|
||||
"LS.PlayerID = P.PlayerID",
|
||||
);
|
||||
$types = "iss";
|
||||
$params = array($maestro_id, $start_date, $end_date);
|
||||
|
||||
case 1002: // korean test
|
||||
$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";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$subject_statement = $subject_statement."A.AppID = ".$app_id;
|
||||
if (strlen($player_name) > 0) {
|
||||
$where[] = "P.Name LIKE ?";
|
||||
$types .= "s";
|
||||
$params[] = "%" . $player_name . "%";
|
||||
}
|
||||
|
||||
return $subject_statement." AND LS.AppID = A.AppID";
|
||||
}
|
||||
|
||||
function makePlayerNameStatement($player_name_list) {
|
||||
$player_name_statement = "LS.PlayerID = P.PlayerID";
|
||||
if(strlen($player_name_list) > 0)
|
||||
$player_name_statement = $player_name_statement." AND P.Name LIKE '%".$player_name_list."%'";
|
||||
|
||||
return $player_name_statement;
|
||||
}
|
||||
|
||||
|
||||
function is_subject_bundle_item($app_id) {
|
||||
if($app_id >= 1000)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
return $where_statement;
|
||||
}
|
||||
|
||||
/*
|
||||
function get_player_record_count($maestro_id, $where_statement, $limit_count) {
|
||||
global $db_conn;
|
||||
$range = get_subject_app_range($app_id);
|
||||
if ($range !== null) {
|
||||
$where[] = "LS.AppID BETWEEN ? AND ?";
|
||||
$types .= "ii";
|
||||
$params[] = $range[0];
|
||||
$params[] = $range[1];
|
||||
}
|
||||
|
||||
$query = "
|
||||
SELECT COUNT(*)
|
||||
FROM license_score LS, player P
|
||||
WHERE LS.MaestroID = ? AND ".$where_statement."
|
||||
";
|
||||
|
||||
if($limit_count > 0)
|
||||
$query = $query." LIMIT ".$limit_count;
|
||||
|
||||
// echo $query;
|
||||
// return;
|
||||
WHERE " . implode(" AND ", $where);
|
||||
|
||||
$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 license_score LS, player P
|
||||
WHERE LS.MaestroID = ? AND ".$where_statement."
|
||||
";
|
||||
|
||||
// echo $query;
|
||||
// return;
|
||||
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param("i", $maestro_id);
|
||||
$stmt->bind_param($types, ...$params);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($record_count);
|
||||
$stmt->fetch();
|
||||
@@ -163,38 +75,62 @@ function get_player_record_total_count($maestro_id, $where_statement) {
|
||||
return $record_count;
|
||||
}
|
||||
|
||||
function get_player_record_list($maestro_id, $where_statement, $limit_count) {
|
||||
|
||||
function get_player_record_list($maestro_id, $start_date, $end_date, $player_name, $app_id, $limit_count) {
|
||||
global $db_conn;
|
||||
|
||||
$where = array(
|
||||
"LS.MaestroID = ?",
|
||||
"LS.ScoreDateTime >= DATE(?)",
|
||||
"LS.ScoreDateTime < DATE(?) + INTERVAL 1 DAY",
|
||||
"LS.PlayerID = P.PlayerID",
|
||||
);
|
||||
$types = "iss";
|
||||
$params = array($maestro_id, $start_date, $end_date);
|
||||
|
||||
if (strlen($player_name) > 0) {
|
||||
$where[] = "P.Name LIKE ?";
|
||||
$types .= "s";
|
||||
$params[] = "%" . $player_name . "%";
|
||||
}
|
||||
|
||||
$range = get_subject_app_range($app_id);
|
||||
if ($range !== null) {
|
||||
$where[] = "LS.AppID BETWEEN ? AND ?";
|
||||
$types .= "ii";
|
||||
$params[] = $range[0];
|
||||
$params[] = $range[1];
|
||||
}
|
||||
|
||||
$query = "
|
||||
SELECT LS.LicenseScoreID AS ID, DATE(LS.ScoreDateTime) AS Date, TIME(LS.ScoreDateTime) AS Time,
|
||||
P.Name AS Name, LS.SubjectName AS Subject, LS.Score AS Record
|
||||
SELECT LS.LicenseScoreID, DATE(LS.ScoreDateTime), TIME(LS.ScoreDateTime),
|
||||
P.Name, LS.SubjectName, LS.Score
|
||||
FROM license_score LS, player P
|
||||
WHERE LS.MaestroID = ? AND ".$where_statement."
|
||||
ORDER BY LS.ScoreDateTime DESC
|
||||
";
|
||||
WHERE " . implode(" AND ", $where) . "
|
||||
ORDER BY LS.ScoreDateTime DESC";
|
||||
|
||||
if($limit_count > 0)
|
||||
$query = $query." LIMIT ".$limit_count;
|
||||
|
||||
// echo $query;
|
||||
// return;
|
||||
if ($limit_count > 0) {
|
||||
$query .= " LIMIT ?";
|
||||
$types .= "i";
|
||||
$params[] = $limit_count;
|
||||
}
|
||||
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('i', $maestro_id);
|
||||
$stmt->bind_param($types, ...$params);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($id, $date, $time, $player_name, $subject, $record);
|
||||
$stmt->bind_result($id, $date, $time, $player_name_result, $subject, $record);
|
||||
|
||||
$record_array = array();
|
||||
while($stmt->fetch()) {
|
||||
$record_date['Id'] = $id;
|
||||
$record_date['Date'] = $date;
|
||||
$record_date['Time'] = $time;
|
||||
$record_date['PlayerName'] = $player_name;
|
||||
$record_date['Subject'] = $subject;
|
||||
$record_date['Record'] = $record;
|
||||
array_push($record_array, $record_date);
|
||||
$record_date['Id'] = $id;
|
||||
$record_date['Date'] = $date;
|
||||
$record_date['Time'] = $time;
|
||||
$record_date['PlayerName'] = $player_name_result;
|
||||
$record_date['Subject'] = $subject;
|
||||
$record_date['Record'] = $record;
|
||||
array_push($record_array, $record_date);
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
return $record_array;
|
||||
}
|
||||
|
||||
@@ -5,37 +5,15 @@ include "./../lib/send_reply_json.php";
|
||||
include "./../lib/maestro_account_info.php";
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
$maestro_id = $_POST["MaestroID"];
|
||||
$maestro_id = (int)$_POST["MaestroID"];
|
||||
$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";
|
||||
$player_name = trim($_POST["PlayerNameList"]);
|
||||
$app_id = (int)$_POST["AppID"];
|
||||
$limit_count = (int)$_POST["LimitCount"];
|
||||
|
||||
$date_statement = makeDateStatement($start_date, $end_date);
|
||||
$player_name_statement = makePlayerNameStatement($player_name_list);
|
||||
$subject_statement = makeSubjectSentence($app_id);
|
||||
$where_statement = make_where_statement($date_statement, $player_name_statement, $subject_statement);
|
||||
// echo "maestro : ".$maestro_id."\n";
|
||||
// echo "date : ".$date_statement."\n";
|
||||
// echo "player_name : ".$player_name_statement."\n";
|
||||
// echo "subject : ".$subject_statement."\n";
|
||||
// echo "where_statement : ".$where_statement."\n";
|
||||
|
||||
$recordTotalCount = get_player_record_total_count($maestro_id, $where_statement);
|
||||
// echo "recordTotalCount : ".$recordTotalCount."\n";
|
||||
$replyJSON = get_player_record_list($maestro_id, $where_statement, $limit_count);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "오늘의 랭킹 기록 없음");
|
||||
$db_conn->close();
|
||||
exit;
|
||||
}
|
||||
$recordTotalCount = get_player_record_total_count($maestro_id, $start_date, $end_date, $player_name, $app_id);
|
||||
$replyJSON = get_player_record_list($maestro_id, $start_date, $end_date, $player_name, $app_id, $limit_count);
|
||||
|
||||
set_data("RecordTotalCount", $recordTotalCount);
|
||||
set_data("RecordList", $replyJSON);
|
||||
@@ -43,84 +21,48 @@ send_result_success();
|
||||
exit;
|
||||
|
||||
|
||||
function get_player_record_total_count($maestro_id, $start_date, $end_date, $player_name, $app_id) {
|
||||
global $db_conn;
|
||||
|
||||
$where = array(
|
||||
"TE.MaestroID = ?",
|
||||
"TE.RecordDateTime >= DATE(?)",
|
||||
"TE.RecordDateTime < DATE(?) + INTERVAL 1 DAY",
|
||||
"TE.PlayerID = P.PlayerID",
|
||||
"TE.WritingID = WR.WritingID",
|
||||
);
|
||||
$types = "iss";
|
||||
$params = array($maestro_id, $start_date, $end_date);
|
||||
|
||||
function makeDateStatement($start_date, $end_date) {
|
||||
return " '".$start_date."' <= TE.RecordDateTime AND TE.RecordDateTime <= DATE_ADD('".$end_date."', INTERVAL 1 DAY)";
|
||||
// return " '".$start_date."' <= TE.RecordDateTime AND TE.RecordDateTime <= '".$end_date."'";
|
||||
// return " '2017-01-01' < TE.RecordDateTime";
|
||||
// return " '2017-01-01' < TE.RecordDateTime AND TE.RecordDateTime < '".$end_date."'";
|
||||
}
|
||||
|
||||
function makeSubjectSentence($app_id) {
|
||||
if($app_id == 0)
|
||||
return "";
|
||||
|
||||
$subject_statement = "";
|
||||
if(is_subject_bundle_item($app_id)) {
|
||||
switch($app_id) {
|
||||
case 1004: // korean exam
|
||||
$subject_statement = $subject_statement."WR.Language='korean'";
|
||||
break;
|
||||
|
||||
case 1005: // english exam
|
||||
$subject_statement = $subject_statement."WR.Language='english'";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$subject_statement = $subject_statement."WR.WritingID=".$app_id;
|
||||
if (strlen($player_name) > 0) {
|
||||
$where[] = "P.Name LIKE ?";
|
||||
$types .= "s";
|
||||
$params[] = "%" . $player_name . "%";
|
||||
}
|
||||
|
||||
return $subject_statement." AND TE.WritingID=WR.WritingID";
|
||||
}
|
||||
|
||||
function makePlayerNameStatement($player_name_list) {
|
||||
$player_name_statement = "TE.PlayerID=P.PlayerID";
|
||||
if(strlen($player_name_list) > 0)
|
||||
$player_name_statement = $player_name_statement." AND P.Name LIKE '%".$player_name_list."%'";
|
||||
|
||||
return $player_name_statement;
|
||||
}
|
||||
|
||||
|
||||
function is_subject_bundle_item($app_id) {
|
||||
if($app_id >= 1000)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
return $where_statement;
|
||||
}
|
||||
|
||||
function get_player_record_total_count($maestro_id, $where_statement) {
|
||||
global $db_conn;
|
||||
if ($app_id > 0) {
|
||||
if ($app_id == 1004) {
|
||||
$where[] = "WR.Language = ?";
|
||||
$types .= "s";
|
||||
$params[] = "korean";
|
||||
} else if ($app_id == 1005) {
|
||||
$where[] = "WR.Language = ?";
|
||||
$types .= "s";
|
||||
$params[] = "english";
|
||||
} else {
|
||||
$where[] = "WR.WritingID = ?";
|
||||
$types .= "i";
|
||||
$params[] = $app_id;
|
||||
}
|
||||
}
|
||||
|
||||
$query = "
|
||||
SELECT COUNT(*)
|
||||
FROM typing_exam_record TE, player P, writing WR
|
||||
WHERE TE.MaestroID = ? AND ".$where_statement."
|
||||
";
|
||||
|
||||
// echo $query;
|
||||
// return;
|
||||
WHERE " . implode(" AND ", $where);
|
||||
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param("i", $maestro_id);
|
||||
$stmt->bind_param($types, ...$params);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($record_count);
|
||||
$stmt->fetch();
|
||||
@@ -129,38 +71,71 @@ function get_player_record_total_count($maestro_id, $where_statement) {
|
||||
return $record_count;
|
||||
}
|
||||
|
||||
function get_player_record_list($maestro_id, $where_statement, $limit_count) {
|
||||
|
||||
function get_player_record_list($maestro_id, $start_date, $end_date, $player_name, $app_id, $limit_count) {
|
||||
global $db_conn;
|
||||
|
||||
$where = array(
|
||||
"TE.MaestroID = ?",
|
||||
"TE.RecordDateTime >= DATE(?)",
|
||||
"TE.RecordDateTime < DATE(?) + INTERVAL 1 DAY",
|
||||
"TE.PlayerID = P.PlayerID",
|
||||
"TE.WritingID = WR.WritingID",
|
||||
);
|
||||
$types = "iss";
|
||||
$params = array($maestro_id, $start_date, $end_date);
|
||||
|
||||
if (strlen($player_name) > 0) {
|
||||
$where[] = "P.Name LIKE ?";
|
||||
$types .= "s";
|
||||
$params[] = "%" . $player_name . "%";
|
||||
}
|
||||
|
||||
if ($app_id > 0) {
|
||||
if ($app_id == 1004) {
|
||||
$where[] = "WR.Language = ?";
|
||||
$types .= "s";
|
||||
$params[] = "korean";
|
||||
} else if ($app_id == 1005) {
|
||||
$where[] = "WR.Language = ?";
|
||||
$types .= "s";
|
||||
$params[] = "english";
|
||||
} else {
|
||||
$where[] = "WR.WritingID = ?";
|
||||
$types .= "i";
|
||||
$params[] = $app_id;
|
||||
}
|
||||
}
|
||||
|
||||
$query = "
|
||||
SELECT TE.TypingExamRecordID as Id, DATE(TE.RecordDateTime) AS Date, TIME(TE.RecordDateTime) AS Time,
|
||||
P.Name AS Name, WR.Name AS Subject, TE.Record AS Record
|
||||
SELECT TE.TypingExamRecordID, DATE(TE.RecordDateTime), TIME(TE.RecordDateTime),
|
||||
P.Name, WR.Name, TE.Record
|
||||
FROM typing_exam_record TE, player P, writing WR
|
||||
WHERE TE.MaestroID = ? AND TE.WritingID=WR.WritingID AND TE.PlayerID=P.PlayerID AND ".$where_statement."
|
||||
ORDER BY TE.RecordDateTime DESC
|
||||
";
|
||||
WHERE " . implode(" AND ", $where) . "
|
||||
ORDER BY TE.RecordDateTime DESC";
|
||||
|
||||
if($limit_count > 0)
|
||||
$query = $query." LIMIT ".$limit_count;
|
||||
|
||||
// echo $query;
|
||||
// return;
|
||||
if ($limit_count > 0) {
|
||||
$query .= " LIMIT ?";
|
||||
$types .= "i";
|
||||
$params[] = $limit_count;
|
||||
}
|
||||
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('i', $maestro_id);
|
||||
$stmt->bind_param($types, ...$params);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($id, $date, $time, $player_name, $subject, $record);
|
||||
$stmt->bind_result($id, $date, $time, $player_name_result, $subject, $record);
|
||||
|
||||
$record_array = array();
|
||||
while($stmt->fetch()) {
|
||||
$record_date['Id'] = $id;
|
||||
$record_date['Date'] = $date;
|
||||
$record_date['Time'] = $time;
|
||||
$record_date['PlayerName'] = $player_name;
|
||||
$record_date['Subject'] = $subject;
|
||||
$record_date['Record'] = $record;
|
||||
array_push($record_array, $record_date);
|
||||
$record_date['Id'] = $id;
|
||||
$record_date['Date'] = $date;
|
||||
$record_date['Time'] = $time;
|
||||
$record_date['PlayerName'] = $player_name_result;
|
||||
$record_date['Subject'] = $subject;
|
||||
$record_date['Record'] = $record;
|
||||
array_push($record_array, $record_date);
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
return $record_array;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user