-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_taskODT_validation.php
128 lines (115 loc) · 3.57 KB
/
admin_taskODT_validation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?session_start()?>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<?php
$id = $_SESSION['id'];
include 'basic.php';
$taskiidd=$_GET['taskid'];
$taskname=$taskiidd;
$query = "SELECT * FROM Task Where Name ='$taskiidd'";
$TS_result = mysql_query($query, $con);
if(!$TS_result){
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
$temp = mysql_fetch_array($TS_result);
$db_task_table_schema = $temp["TaskDataTableSchemaInfo"];
$words = explode(" ", $db_task_table_schema);
$words_count = count($words);
//$key = array_search("나이1", array_values($words));
//기타 추가.. : attribute갯수 정할 수 있게 하기
//원본스키마 1개 이상이므로, 태스크 등록하자마자 바로 등록할 수 있게하기
// $taskname
$ODTname = $_POST['ODTname'];
$query = "select count(*) from Original_Data_Type where ID='$ODTname'";
$result = mysql_query($query,$con);
if(!$result){
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
$r1 = mysql_fetch_row($result);
if($r1[0]>0){
echo "<script>alert('중복된 원본 데이터 타입 이름입니다.');history.back();</script>";
}
$tasktableschema ="";
$mappinginfo ="";
for($i = 1 ; $i <=20 ; $i++){
$tempname = 'name';
$tempname .= $i;
$realname = $_POST[$tempname];
$temptype = 'type';
$temptype .= $i;
$realtype = $_POST[$temptype];
$templength = 'length';
$templength .= $i;
$reallength = $_POST[$templength];
$tempmapping = 'mapping';
$tempmapping .= $i;
$realmapping = $_POST[$tempmapping];
if(!empty($realname)){
if($realmapping=='NULL'){
$mappinginfo .= "NULL";
$tasktableschema .= $realname;
$tasktableschema .= " ";
$tasktableschema .= $realtype;
if($realtype=='char'){
if($reallength==""){
$reallength="1";
}
}
if($realtype=='int'){
if($reallength==""){
$reallength="11";
}
}
if($realtype=='tinyint'){
if($reallength==""){
$reallength="4";
}
}
if($realtype=='varchar' || $realtype=='char' || $realtype=='int' || $realtype=='tinyint'){
$tasktableschema .= "(";
$tasktableschema .= $reallength;
$tasktableschema .= ")";
}
}
else{ //not null
$mappinginfo .= $realmapping;
$tasktableschema .= $realname;
$tasktableschema .= " ";
$key = array_search($realmapping, array_values($words));
$parsedtype = $words[$key+1];
$tasktableschema .= $parsedtype;
}
$mappinginfo .= " ";
$tasktableschema .= " ";
}
}
if($r1[0]==0)
{
$query = "insert into Original_Data_Type (ID, SchemaInfo, TaskName, MappingInfo) ";
$query.= "values ('$ODTname','$tasktableschema','$taskname','$mappinginfo')";
$result = mysql_query($query, $con);
if(!$result)
{
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
else
{
$addODTurl = "admin_taskODT.php";
$addODTurl = $addODTurl . "?";
$addODTurl = $addODTurl . "taskname=";
$addODTurl = $addODTurl . $taskiidd;// 안되면 '' 지워보기.
echo "<script>alert('ODT 생성 성공!');
location.replace('".$addODTurl."');
</script>";
}
}
?>
</body>
</html>