64 lines
1.6 KiB
PHP
64 lines
1.6 KiB
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
|
|
include "./../lib/send_reply_json.php";
|
|
include "./../setup/connect_db.php";
|
|
|
|
$maestroID = $_POST["maestro_id"];
|
|
$registeredAcountType = $_POST["registered_account_type"];
|
|
$newAccountType = $_POST["new_account_type"];
|
|
|
|
|
|
// $maestroID = has_maestro_name($maestro_name);
|
|
// if($maestroID !== null) {
|
|
// set_error_message($maestro_name." : 이미 등록된 마에스트로 계정입니다.");
|
|
// send_result_fail();
|
|
// exit;
|
|
// }
|
|
|
|
add_maestro_update($maestroID, $registeredAcountType, $newAccountType);
|
|
|
|
$countUpgrade = count_maestro_upgrade($maestroID);
|
|
if($countUpgrade === null || $countUpgrade < 1) {
|
|
set_error_message($maestro_name." : 알 수 없는 이유로 마에스트로 계정 업그레이드 요청이 취소되었습니다.");
|
|
send_result_fail();
|
|
exit;
|
|
}
|
|
|
|
send_result_success();
|
|
exit;
|
|
|
|
|
|
|
|
function count_maestro_upgrade($maestroID) {
|
|
global $db_conn;
|
|
|
|
$query = "
|
|
SELECT COUNT(MaestroID)
|
|
FROM moty_maestro_upgrade
|
|
WHERE MaestroID = ?
|
|
";
|
|
$stmt = $db_conn->prepare($query);
|
|
$stmt->bind_param("i", $maestroID);
|
|
$stmt->execute();
|
|
$stmt->bind_result($countUpgrade);
|
|
// while($stmt->fetch())
|
|
$stmt->fetch();
|
|
$stmt->close();
|
|
|
|
return $countUpgrade;
|
|
}
|
|
|
|
function add_maestro_update($maestroID, $registeredAcountType, $newAccountType) {
|
|
global $db_conn;
|
|
|
|
$query = "
|
|
INSERT INTO moty_maestro_upgrade (RegisteredAccountType, RequestedAccountType, RequestedDateTime, Status, MaestroID)
|
|
VALUES (?, ?, NOW(), 1, ?);
|
|
";
|
|
$stmt = $db_conn->prepare($query);
|
|
$stmt->bind_param("iii", $registeredAcountType, $newAccountType, $maestroID);
|
|
$stmt->execute();
|
|
}
|
|
|
|
?>
|