Fix: DB user column -> player

This commit is contained in:
2018-07-04 21:54:29 +09:00
parent 81860d6800
commit dc87390b8c
26 changed files with 132 additions and 132 deletions
+1 -1
View File
@@ -69,7 +69,7 @@ class PlayerList {
$(this.listRows[i].playerID).empty();
if(i < jsonData.length) {
$(this.listRows[i].playerID).append(jsonData[i]["UserID"]);
$(this.listRows[i].playerID).append(jsonData[i]["PlayerID"]);
$(this.listRows[i].playerName).val(jsonData[i]["Name"]);
$(this.listRows[i].enterCode).val(jsonData[i]["EnterCode"]);
+8 -8
View File
@@ -21,7 +21,7 @@
let self = this;
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/user/registered_player_count.php', true);
xhr.open('POST', './../server/player/registered_player_count.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("maestro_id=" + maestroID);
xhr.onload = function() {
@@ -70,7 +70,7 @@
let endNo = pageIndex * 10 + 9;
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/user/registered_player_list.php', true);
xhr.open('POST', './../server/player/registered_player_list.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo);
xhr.onload = function() {
@@ -119,7 +119,7 @@
let endNo = pageIndex * 10 + 9;
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/user/registered_player_list.php', true);
xhr.open('POST', './../server/player/registered_player_list.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo);
xhr.onload = function() {
@@ -153,7 +153,7 @@
self.list.updatePlayerList(replyJSON["PlayerList"]);
self.playerCount = replyJSON["PlayerList"].length;
console.log(self.playerCount);
// console.log(self.playerCount);
// self.lastPageNo = Math.ceil( (self.playerCount + 1) / 10 );
// self.activePageNo = 1;
@@ -168,7 +168,7 @@
let self = this;
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/user/search_player_count.php', true);
xhr.open('POST', './../server/player/search_player_count.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("maestro_id=" + maestroID + "&player_name=" + playerName);
xhr.onload = function() {
@@ -216,7 +216,7 @@
let endNo = pageIndex * 10 + 9;
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/user/search_player_list.php', true);
xhr.open('POST', './../server/player/search_player_list.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("maestro_id=" + maestroID + "&player_name=" + playerName + "&start_no=" + startNo + "&end_no=" + endNo);
xhr.onload = function() {
@@ -306,7 +306,7 @@
// console.log(playerEnterCode);
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/user/edit_player.php', true);
xhr.open('POST', './../server/player/edit_player.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("maestro_id=" + maestroID + "&player_id=" + playerID + "&player_name=" + playerName + "&enter_code=" + playerEnterCode);
xhr.onload = function() {
@@ -359,7 +359,7 @@
return;
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/user/delete_player.php', true);
xhr.open('POST', './../server/player/delete_player.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("maestro_id=" + maestroID + "&player_id=" + playerID);
xhr.onload = function() {
@@ -25,7 +25,7 @@ function addPlayer() {
}
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/user/add_player.php', true);
xhr.open('POST', './../server/player/add_player.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("maestro_id=" + maestroID + "&player_name=" + playerName + "&enter_code=" + enterCode);
xhr.onload = function() {
@@ -84,14 +84,14 @@ function addPlayer() {
<!--
<h3>단체 추가</h3>
<form action="/action_page.php" method="get" id="add_users">
<form action="/action_page.php" method="get" id="add_players">
<textarea>
엑셀에서 아래와 같이 셀에 입력한 후에 복사하고 붙여넣기
학생 이름 | 입장 코드
학생 이름 | 입장 코드
...
</textarea>
<button type="submit" form="add_users">추가</button>
<button type="submit" form="add_players">추가</button>
</form>
<textarea>
@@ -41,23 +41,22 @@ if($result === null) {
function hasPlayerName($maestroID, $playerName, $enterCode) {
global $db_conn;
$query = "SELECT UserID FROM moty_user WHERE MaestroID=? AND Name=? AND EnterCode=?";
$query = "SELECT PlayerID FROM moty_player WHERE MaestroID=? AND Name=? AND EnterCode=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('iss', $maestroID, $playerName, $enterCode);
$stmt->execute();
$stmt->bind_result($userID);
$stmt->bind_result($playerID);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
// $replyJSON["UserID"] = $userID;
return $userID;
return $playerID;
}
function addPlayer($maestroID, $playerName, $enterCode) {
global $db_conn;
$query = "INSERT INTO moty_user (MaestroID, Name, EnterCode) VALUES (?, ?, ?)";
$query = "INSERT INTO moty_player (MaestroID, Name, EnterCode) VALUES (?, ?, ?)";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('iss', $maestroID, $playerName, $enterCode);
$stmt->execute();
@@ -37,7 +37,7 @@ $db_conn->close();
function deletePlayer($maestroID, $playerID) {
global $db_conn;
$query = "DELETE FROM moty_best_record WHERE MaestroID = ? AND UserID = ?";
$query = "DELETE FROM moty_best_record WHERE MaestroID = ? AND PlayerID = ?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('ii', $maestroID, $playerID);
$result = $stmt->execute();
@@ -47,7 +47,7 @@ function deletePlayer($maestroID, $playerID) {
// echo "deleted row count : ".$stmt->affected_rows;
// }
$query = "DELETE FROM moty_user WHERE MaestroID = ? AND UserID = ?";
$query = "DELETE FROM moty_player WHERE MaestroID = ? AND PlayerID = ?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('ii', $maestroID, $playerID);
$result = $stmt->execute();
@@ -61,16 +61,16 @@ function deletePlayer($maestroID, $playerID) {
function hasPlayerID($maestroID, $playerID) {
global $db_conn;
$query = "SELECT UserID FROM moty_user WHERE MaestroID=? AND UserID=?";
$query = "SELECT PlayerID FROM moty_player WHERE MaestroID=? AND PlayerID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('ii', $maestroID, $playerID);
$stmt->execute();
$stmt->bind_result($userID);
$stmt->bind_result($playerID);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
if($userID !== null)
if($playerID !== null)
return true;
return false;
@@ -79,16 +79,16 @@ function hasPlayerID($maestroID, $playerID) {
function hasPlayerRecord($maestroID, $playerID) {
global $db_conn;
$query = "SELECT UserID FROM moty_best_record WHERE MaestroID=? AND UserID=?";
$query = "SELECT PlayerID FROM moty_best_record WHERE MaestroID=? AND PlayerID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('ii', $maestroID, $playerID);
$stmt->execute();
$stmt->bind_result($userID);
$stmt->bind_result($playerID);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
if($userID !== null)
if($playerID !== null)
return true;
return false;
@@ -39,23 +39,22 @@ $db_conn->close();
function hasSamePlayerData($maestroID, $playerID, $playerName, $enterCode) {
global $db_conn;
$query = "SELECT UserID FROM moty_user WHERE MaestroID=? AND UserID<>? AND Name=? AND EnterCode=?";
$query = "SELECT PlayerID FROM moty_player WHERE MaestroID=? AND PlayerID<>? AND Name=? AND EnterCode=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('iiss', $maestroID, $playerID, $playerName, $enterCode);
$stmt->execute();
$stmt->bind_result($userID);
$stmt->bind_result($playerID);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
// $replyJSON["UserID"] = $userID;
return $userID;
return $playerID;
}
function editPlayer($maestroID, $playerID, $playerName, $enterCode) {
global $db_conn;
$query = "UPDATE moty_user SET Name=?, EnterCode=? WHERE MaestroID=? AND UserID=?";
$query = "UPDATE moty_player SET Name=?, EnterCode=? WHERE MaestroID=? AND PlayerID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('ssii', $playerName, $enterCode, $maestroID, $playerID);
$stmt->execute();
@@ -64,17 +63,16 @@ function editPlayer($maestroID, $playerID, $playerName, $enterCode) {
function hasPlayerName($maestroID, $playerName, $enterCode) {
global $db_conn;
$query = "SELECT UserID FROM moty_user WHERE MaestroID=? AND Name=? AND EnterCode=?";
$query = "SELECT PlayerID FROM moty_player WHERE MaestroID=? AND Name=? AND EnterCode=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('iss', $maestroID, $playerName, $enterCode);
$stmt->execute();
$stmt->bind_result($userID);
$stmt->bind_result($playerID);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
// $replyJSON["UserID"] = $userID;
return $userID;
return $playerID;
}
?>
@@ -24,7 +24,7 @@ if($maestroID === null) {
}
$replyJSON = get_login_data($maestroID, $name, $enterCode);
if($replyJSON["UserID"] === null) {
if($replyJSON["PlayerID"] === null) {
send_error_message($replyJSON, "입력한 이름/입장번호와 일치하는 계정이 없습니다");
$db_conn->close();
exit;
@@ -54,17 +54,17 @@ function get_maestro_id($maestroName) {
function get_login_data($maestroID, $name, $enterCode) {
global $db_conn;
$query = "SELECT UserID FROM moty_user WHERE MaestroID=? AND Name=? AND EnterCode=?";
$query = "SELECT PlayerID FROM moty_player WHERE MaestroID=? AND Name=? AND EnterCode=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('iss', $maestroID, $name, $enterCode);
$stmt->execute();
$stmt->bind_result($user_id);
$stmt->bind_result($player_id);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
$replyJSON["MaestroID"] = $maestroID;
$replyJSON["UserID"] = $user_id;
$replyJSON["PlayerID"] = $player_id;
return $replyJSON;
}
@@ -30,15 +30,15 @@ $db_conn->close();
function getPlayerCount($maestroID) {
global $db_conn;
$query = "SELECT COUNT(UserID) FROM moty_user WHERE MaestroID=?";
$query = "SELECT COUNT(PlayerID) FROM moty_player WHERE MaestroID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('i', $maestroID);
$stmt->execute();
$stmt->bind_result($userCount);
$stmt->bind_result($playerCount);
$stmt->fetch();
$stmt->close();
return $userCount;
return $playerCount;
}
?>
@@ -24,20 +24,20 @@ function get_player_list_page($maestroID, $startNo, $endNo) {
global $db_conn;
$query = "
SELECT UserID, Name, EnterCode FROM moty_user
SELECT PlayerID, Name, EnterCode FROM moty_player
WHERE MaestroID=?
ORDER BY UserID DESC
ORDER BY PlayerID DESC
LIMIT ?, 10;
";
$stmt = $db_conn->prepare($query);
// $stmt->bind_param('iii', $maestroID, $startNo, $endNo);
$stmt->bind_param('ii', $maestroID, $startNo);
$stmt->execute();
$stmt->bind_result($userID, $name, $enterCode);
$stmt->bind_result($playerID, $name, $enterCode);
$playerList = array();
while($stmt->fetch()) {
$player['UserID'] = $userID;
$player['PlayerID'] = $playerID;
$player['Name'] = $name;
$player['EnterCode'] = $enterCode;
array_push($playerList, $player);
@@ -31,15 +31,15 @@ $db_conn->close();
function getPlayerCount($maestroID, $playerName) {
global $db_conn;
$query = "SELECT COUNT(UserID) FROM moty_user WHERE MaestroID = ? AND Name = ?";
$query = "SELECT COUNT(PlayerID) FROM moty_player WHERE MaestroID = ? AND Name = ?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('is', $maestroID, $playerName);
$stmt->execute();
$stmt->bind_result($userCount);
$stmt->bind_result($playerCount);
$stmt->fetch();
$stmt->close();
return $userCount;
return $playerCount;
}
?>
@@ -25,20 +25,20 @@ function get_player_list_page($maestroID, $playerName, $startNo, $endNo) {
global $db_conn;
$query = "
SELECT UserID, Name, EnterCode FROM moty_user
SELECT PlayerID, Name, EnterCode FROM moty_player
WHERE MaestroID=? AND Name=?
ORDER BY UserID DESC
ORDER BY PlayerID DESC
LIMIT ?, 10;
";
$stmt = $db_conn->prepare($query);
// $stmt->bind_param('iii', $maestroID, $startNo, $endNo);
$stmt->bind_param('isi', $maestroID, $playerName, $startNo);
$stmt->execute();
$stmt->bind_result($userID, $name, $enterCode);
$stmt->bind_result($playerID, $name, $enterCode);
$playerList = array();
while($stmt->fetch()) {
$player['UserID'] = $userID;
$player['PlayerID'] = $playerID;
$player['Name'] = $name;
$player['EnterCode'] = $enterCode;
array_push($playerList, $player);
+5 -5
View File
@@ -3,13 +3,13 @@ header('Content-Type: application/json');
$maestro_id = $_POST["MaestroID"];
$app_id = $_POST["AppID"];
$user_id = $_POST["UserID"];
$player_id = $_POST["PlayerID"];
$date = $_POST["Date"];
include "./../setup/connect_db.php";
$replyJSON = get_history_record($maestro_id, $app_id, $user_id, $date);
$replyJSON = get_history_record($maestro_id, $app_id, $player_id, $date);
if($replyJSON.length === 0) {
send_error_message($replyJSON, "히스토리 기록 없음");
$db_conn->close();
@@ -20,20 +20,20 @@ echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
function get_history_record($maestro_id, $app_id, $user_id, $date) {
function get_history_record($maestro_id, $app_id, $player_id, $date) {
global $db_conn;
$query = "
SELECT DATE(BR.RecordDateTime) AS Date, MAX(BR.BestRecord) AS HighScore, AA.AppName AS AppName
FROM moty_best_record BR
INNER JOIN moty_app AS AA
ON BR.MaestroID = ? AND BR.UserID = ? AND DATE(BR.RecordDateTime) <= ? AND BR.AppID = ? AND BR.AppID = AA.AppID
ON BR.MaestroID = ? AND BR.PlayerID = ? AND DATE(BR.RecordDateTime) <= ? AND BR.AppID = ? AND BR.AppID = AA.AppID
GROUP BY DATE(BR.RecordDateTime)
ORDER BY BR.RecordDateTime DESC
LIMIT 7
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('iisi', $maestro_id, $user_id, $date, $app_id);
$stmt->bind_param('iisi', $maestro_id, $player_id, $date, $app_id);
$stmt->execute();
$stmt->bind_result($date, $score, $app_name);
+6 -6
View File
@@ -24,20 +24,20 @@ function get_ranking_record_day($maestro_id, $date, $app_id) {
global $db_conn;
$query = "
SELECT BR.userID As UserID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore
FROM moty_best_record BR, moty_user U
WHERE BR.MaestroID = ? AND BR.userID = U.userID AND DATE(BR.RecordDateTime) = ? AND AppID = ?
GROUP BY BR.userID
SELECT BR.playerID As PlayerID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore
FROM moty_best_record BR, moty_player U
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND DATE(BR.RecordDateTime) = ? AND AppID = ?
GROUP BY BR.playerID
ORDER BY max(BR.BestRecord) DESC;
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('isi', $maestro_id, $date, $app_id);
$stmt->execute();
$stmt->bind_result($userID, $name, $high_score);
$stmt->bind_result($playerID, $name, $high_score);
$ranking_record_array = array();
while($stmt->fetch()) {
$ranking_record['UserID'] = $userID;
$ranking_record['PlayerID'] = $playerID;
$ranking_record['Name'] = $name;
$ranking_record['HighScore'] = $high_score;
array_push($ranking_record_array, $ranking_record);
@@ -23,20 +23,20 @@ function get_ranking_record_hour($maestro_id, $date, $time, $app_id) {
global $db_conn;
$query = "
SELECT BR.userID As UserID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore
FROM moty_best_record BR, moty_user U
WHERE BR.MaestroID = ? AND BR.userID = U.userID AND DATE(BR.RecordDateTime) = ? AND HOUR(BR.RecordDateTime) = HOUR(?) AND AppID = ?
GROUP BY BR.userID
SELECT BR.playerID As PlayerID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore
FROM moty_best_record BR, moty_player U
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND DATE(BR.RecordDateTime) = ? AND HOUR(BR.RecordDateTime) = HOUR(?) AND AppID = ?
GROUP BY BR.playerID
ORDER BY max(BR.BestRecord) DESC;
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('issi', $maestro_id, $date, $time, $app_id);
$stmt->execute();
$stmt->bind_result($userID, $name, $high_score);
$stmt->bind_result($playerID, $name, $high_score);
$ranking_record_array = array();
while($stmt->fetch()) {
$ranking_record['UserID'] = $userID;
$ranking_record['PlayerID'] = $playerID;
$ranking_record['Name'] = $name;
$ranking_record['HighScore'] = $high_score;
array_push($ranking_record_array, $ranking_record);
@@ -24,20 +24,20 @@ function get_ranking_record_month($maestro_id, $date, $time, $app_id) {
global $db_conn;
$query = "
SELECT BR.userID As UserID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore
FROM moty_best_record BR, moty_user U
WHERE BR.MaestroID = ? AND BR.userID = U.userID AND MONTH(BR.RecordDateTime) = MONTH(?) AND AppID = ?
GROUP BY BR.userID
SELECT BR.playerID As PlayerID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore
FROM moty_best_record BR, moty_player U
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND MONTH(BR.RecordDateTime) = MONTH(?) AND AppID = ?
GROUP BY BR.playerID
ORDER BY max(BR.BestRecord) DESC;
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('isi', $maestro_id, $date, $app_id);
$stmt->execute();
$stmt->bind_result($userID, $name, $high_score);
$stmt->bind_result($playerID, $name, $high_score);
$ranking_record_array = array();
while($stmt->fetch()) {
$ranking_record['UserID'] = $userID;
$ranking_record['PlayerID'] = $playerID;
$ranking_record['Name'] = $name;
$ranking_record['HighScore'] = $high_score;
array_push($ranking_record_array, $ranking_record);
@@ -2,14 +2,14 @@
header('Content-Type: application/json');
$maestro_id = $_POST["MaestroID"];
$user_id = $_POST["UserID"];
$player_id = $_POST["PlayerID"];
$app_id = $_POST["AppID"];
include "./../setup/connect_db.php";
$replyJSON = array();
$replyJSON["BestRecord"] = get_best_record($maestro_id, $app_id, $user_id);
$replyJSON["BestRecord"] = get_best_record($maestro_id, $app_id, $player_id);
if($replyJSON.length === 0) {
send_error_message($replyJSON, "히스토리 기록 없음");
$db_conn->close();
@@ -20,16 +20,16 @@ echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
function get_best_record($maestro_id, $app_id, $user_id) {
function get_best_record($maestro_id, $app_id, $player_id) {
global $db_conn;
$query = "
SELECT BestRecord
FROM moty_best_record
WHERE MaestroID = ? AND AppID = ? AND UserID = ? AND DATE(RecordDateTime) = DATE(NOW())
WHERE MaestroID = ? AND AppID = ? AND PlayerID = ? AND DATE(RecordDateTime) = DATE(NOW())
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("iii", $maestro_id, $app_id, $user_id);
$stmt->bind_param("iii", $maestro_id, $app_id, $player_id);
$stmt->execute();
$stmt->bind_result($best_record);
$stmt->fetch();
+10 -10
View File
@@ -2,7 +2,7 @@
header('Content-Type: application/json');
$maestro_id = $_POST["MaestroID"];
$user_id = $_POST["UserID"];
$player_id = $_POST["PlayerID"];
$app_id = $_POST["AppID"];
$best_record = $_POST["BestRecord"];
// echo $best_record." / ";
@@ -12,12 +12,12 @@ include "./../setup/connect_db.php";
$prev_best_record_id = -1;
$prev_best_record = 0;
$prev_best_record_id = get_best_record($maestro_id, $app_id, $user_id);
$prev_best_record_id = get_best_record($maestro_id, $app_id, $player_id);
// echo "id : ".$prev_best_record_id." ".$prev_best_record;
if($prev_best_record_id < 0) {
if($prev_best_record_id === null || $prev_best_record_id < 0) {
// echo "insert";
insert_best_record($maestro_id, $app_id, $user_id, $best_record);
insert_best_record($maestro_id, $app_id, $player_id, $best_record);
} else {
// echo $best_record." ".$prev_best_record;
if($best_record > $prev_best_record) {
@@ -29,17 +29,17 @@ if($prev_best_record_id < 0) {
$db_conn->close();
function get_best_record($maestro_id, $app_id, $user_id) {
function get_best_record($maestro_id, $app_id, $player_id) {
global $db_conn;
global $prev_best_record_id, $prev_best_record;
$query = "
SELECT BestRecordID, BestRecord
FROM moty_best_record
WHERE MaestroID = ? AND AppID = ? AND UserID = ? AND DATE(RecordDateTime) = DATE(NOW()) AND HOUR(RecordDateTime) = HOUR(NOW())
WHERE MaestroID = ? AND AppID = ? AND PlayerID = ? AND DATE(RecordDateTime) = DATE(NOW()) AND HOUR(RecordDateTime) = HOUR(NOW())
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("iii", $maestro_id, $app_id, $user_id);
$stmt->bind_param("iii", $maestro_id, $app_id, $player_id);
$stmt->execute();
$stmt->bind_result($prev_best_record_id, $prev_best_record);
$stmt->fetch();
@@ -52,15 +52,15 @@ function get_best_record($maestro_id, $app_id, $user_id) {
}
function insert_best_record($maestro_id, $app_id, $user_id, $best_record) {
function insert_best_record($maestro_id, $app_id, $player_id, $best_record) {
global $db_conn;
$query = "
INSERT INTO moty_best_record (MaestroID, UserID, AppID, BestRecord, RecordDateTime)
INSERT INTO moty_best_record (MaestroID, PlayerID, AppID, BestRecord, RecordDateTime)
VALUES (?, ?, ?, ?, NOW());
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('iiid', $maestro_id, $user_id, $app_id, $best_record);
$stmt->bind_param('iiid', $maestro_id, $player_id, $app_id, $best_record);
$stmt->execute();
}
+4 -4
View File
@@ -10,8 +10,8 @@ CREATE TABLE moty_maestro (
MaestroTestID INT UNSIGNED
);
CREATE TABLE moty_user (
UserID INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
CREATE TABLE moty_player (
PlayerID INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
MaestroID INT UNSIGNED NOT NULL,
Name CHAR(50) NOT NULL,
EnterCode CHAR(6) NOT NULL,
@@ -44,7 +44,7 @@ CREATE TABLE moty_best_record (
BestRecordID INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
MaestroID INT UNSIGNED NOT NULL,
AppID INT UNSIGNED NOT NULL,
UserID INT UNSIGNED NOT NULL,
PlayerID INT UNSIGNED NOT NULL,
BestRecord FLOAT NOT NULL,
RecordDateTime DATETIME NOT NULL,
@@ -59,7 +59,7 @@ CREATE TABLE moty_ranking (
AppID INT UNSIGNED NOT NULL,
RankingType INT UNSIGNED NOT NULL,
Rank INT UNSIGNED NOT NULL,
UserID INT UNSIGNED NOT NULL,
PlayerID INT UNSIGNED NOT NULL,
FOREIGN KEY (MaestroID) REFERENCES moty_maestro(MaestroID),
FOREIGN KEY (AppID) REFERENCES moty_app(AppID),