Add: test_db_connect_manager
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include "./../lib/send_error_code.php";
|
||||
|
||||
$user_id = $_POST["UserID"];
|
||||
$app_name = $_POST["AppName"];
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
|
||||
// ranking month
|
||||
/*
|
||||
$query = "
|
||||
SELECT D.userID As UserID, U.Name AS Name, MAX(D.Score) AS HighScore
|
||||
FROM moty_record D, moty_user U
|
||||
WHERE D.userID = U.userID AND MONTH(D.DateTime) = MONTH(NOW()) AND AppName = ?
|
||||
GROUP BY D.userID
|
||||
ORDER BY max(D.Score) DESC;
|
||||
";
|
||||
*/
|
||||
$query = "
|
||||
SELECT D.userID As UserID, U.Name AS Name, MAX(D.Score) AS HighScore
|
||||
FROM moty_record D, moty_user U
|
||||
WHERE D.userID = U.userID AND MONTH(D.DateTime) = MONTH('2018-05-18') AND AppName = 'korean_word'
|
||||
GROUP BY D.userID
|
||||
ORDER BY max(D.Score) DESC;
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('s', $app_name);
|
||||
$stmt->execute();
|
||||
|
||||
$stmt->bind_result($userID, $name, $high_score);
|
||||
|
||||
$score_record_array = array();
|
||||
while($stmt->fetch()) {
|
||||
$score_record['UserID'] = $userID;
|
||||
$score_record['Name'] = $name;
|
||||
$score_record['HighScore'] = $high_score;
|
||||
array_push($score_record_array, $score_record);
|
||||
}
|
||||
$return_array['rankingMonth'] = $score_record_array;
|
||||
|
||||
echo json_encode($return_array, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
|
||||
$db_conn->close();
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user