Add: insert active apps for new maestro as registrating

This commit is contained in:
2018-09-05 23:45:51 +09:00
parent ba1d95932e
commit dfbd7b9df3
+36 -1
View File
@@ -6,7 +6,6 @@ include "./../setup/connect_db.php";
$maestroID = $_POST["maestro_id"]; $maestroID = $_POST["maestro_id"];
$result = register_maestro($maestroID); $result = register_maestro($maestroID);
if($result <= 0) { if($result <= 0) {
set_error_message("마에스트로 계정 활성화 실패"); set_error_message("마에스트로 계정 활성화 실패");
@@ -30,6 +29,8 @@ if($result === null || $result === 0) {
exit; exit;
} }
add_default_activated_apps($maestroID);
send_result_success(); send_result_success();
exit; exit;
@@ -94,4 +95,38 @@ function set_maestro_test_player($maestroID, $playerID) {
return $stmt->affected_rows; return $stmt->affected_rows;
} }
function add_default_activated_apps($maestroID) {
global $db_conn;
$query = "
SELECT AppID
FROM app
WHERE Status = 1;
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestroID);
$stmt->execute();
$stmt->bind_result($appID);
$activeAppList = array();
while($stmt->fetch()) {
array_push($activeAppList, $appID);
}
$stmt->close();
$count = count($activeAppList);
for($i = 0; $i < $count; $i++) {
$activeAppID = $activeAppList[$i];
$query = "
INSERT INTO active_app (MaestroID, AppID)
VALUES (?, ?);
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("ii", $maestroID, $activeAppID);
$stmt->execute();
$stmt->close();
}
}
?> ?>