Add: typing practice app button

This commit is contained in:
2018-06-03 15:15:48 +09:00
parent e3bcd3bb12
commit 024145b609
4 changed files with 136 additions and 16 deletions
@@ -0,0 +1,49 @@
<?php
header('Content-Type: application/json');
include "./../send_error_code.php";
$maestro_id = $_POST["maestro_id"];
include "./../setup/connect_db.php";
$replyJSON = get_active_typing_practice_app_list($maestro_id);
$db_conn->close();
if($replyJSON.length === 0) {
send_error_message($replyJSON, "앱 목록 가져오기 실패");
$db_conn->close();
exit;
}
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
function get_active_typing_practice_app_list($maestro_id) {
global $db_conn;
$query = "
SELECT A.AppID, A.AppName, A.AppType
FROM moty_app AS A
INNER JOIN moty_active_app AS AA ON A.AppType < 50 AND A.AppID = AA.AppID AND AA.MaestroID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('i', $maestro_id);
$stmt->execute();
$stmt->bind_result($app_id, $app_name, $app_type);
$return_array = array();
while($stmt->fetch()) {
$row_array['AppID'] = $app_id;
$row_array['AppName'] = $app_name;
$row_array['AppType'] = $app_type;
array_push($return_array, $row_array);
}
$stmt->close();
return $return_array;
}
?>