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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
<? class DBCS { var $db_hostcs; var $db_namecs; var $db_usercs; var $db_passcs; var $debug_modecs; function DBCS($db_hostcs,$db_namecs,$db_usercs,$db_passcs,$debug_modecs='1') { $this->db_hostcs = $db_hostcs; $this->db_namecs = $db_namecs; $this->db_usercs = $db_usercs; $this->db_passcs = $db_passcs; $this->debug_modecs = $debug_modecs; $this->connectcs = @mysql_connect($this->db_hostcs,$this->db_usercs,$this->db_passcs); @mysql_select_db($this->db_namecs,$this->connectcs); } #Å×À̺íÀ» »èÁ¦ function dropTable($table_name) { $qry = 'drop table '.$table_name; return $result = $this->query($qry); } #Äõ¸®¸¸ ³¯¸®¸é µÇ´Â ÇÔ¼ö function queryRow($qry) { if($this->debug_mode) $result = mysql_query($qry,$this->connect) or die($qry.'<br>'.mysql_errno().' : '.mysql_error()); else $result = @mysql_query($qry,$this->connect) or die('Error'); $row = mysql_fetch_array($result); return $row; } #Äõ¸®¸¸ ³¯¸®¸é µÇ´Â ÇÔ¼ö function query($qry) { function query($qry) { if($this->debug_mode) $result = mysql_query($qry,$this->connect) or die($qry.'<br>'.mysql_errno().' : '.mysql_error()); else $result = @mysql_query($qry,$this->connect) or die('Error'); $result = $mysql_query($qry,$this->connect); } if($this->debug_mode) $result = mysql_query($qry,$this->connect) or die($qry.'<br>'.mysql_errno().' : '.mysql_error()); else $result = @mysql_query($qry,$this->connect) or die('Error'); return $result; } #Äõ¸®¸¸ ³¯¸®¸é µÇ´Â ÇÔ¼ö function queryCnt($qry) { if($this->debug_mode) $result['result'] = mysql_query($qry,$this->connect) or die($qry.'<br>'.mysql_errno().' : '.mysql_error()); else $result['result'] = @mysql_query($qry,$this->connect) or die('Error'); $result['cnt'] = mysql_affected_rows(); return $result; } #Äõ¸®¸¸ ³¯¸®¸é µÇ´Â ÇÔ¼ö function queryIdx($qry) { if($this->debug_mode) $result['result'] = mysql_query($qry,$this->connect) or die($qry.'<br>'.mysql_errno().' : '.mysql_error()); else $result['result'] = @mysql_query($qry,$this->connect) or die('Error'); $result['idx'] = mysql_insert_id(); return $result; } #Äõ¸®¿¡ ÇØ´çÇÏ´Â ÁÙ¼ö´Â ³Ñ°ÜÁÖ´Â ÇÔ¼ö function cnt($table_name,$where="",$fields="count(*)") { $qry = 'select '.$fields.' from '.$table_name.' '.$where; $result = $this->query($qry); $row = mysql_fetch_row($result); if(empty($row['0'])) return 0; return $row['0']; } #¼¿·ºÆ®ÇÔ¼ö function select($table_name,$where="",$fields="*") { $qry = 'select '.$fields.' from '.$table_name.' '.$where; return $result = $this->query($qry); } #¼¿·ºÆ®ÇÔ¼ö function selectCnt($table_name,$where="",$fields="*") { $qry = 'select '.$fields.' from '.$table_name.' '.$where; return $result = $this->queryCnt($qry); } #µ¥ÀÌÅÍ ÇѰ³¸¸ °¡Áö°í ¿À´Â ÇÔ¼ö function selectOne($table_name,$where="",$fields) { $qry = 'select '.$fields.' from '.$table_name.' '.$where; $result = $this->query($qry); $row = mysql_fetch_row($result); return $row['0']; } #·¹ÄÚµå ÇѰ³¸¸ °¡Áö°í ¿À´Â ÇÔ¼ö function row($table_name,$where="",$fields="*") { $qry = 'select '.$fields.' from '.$table_name.' '.$where.' limit 1'; $result = $this->query($qry); $row = mysql_fetch_array($result); return $row; } #»èÁ¦ÇÏ´Â ÇÔ¼ö function del($table_name,$where="") { $qry = 'delete from '.$table_name.' '.$where; return $result = $this->query($qry); } #ÀμƮ ÇÔ¼ö ù¹øÂ°²¨ function insert($table_name,$val) { $qry='insert into '.$table_name.' values ('.$val.')'; return $result = $this->query($qry); } #ÀμƮ set ÇÔ¼ö function insertSet($table_name,$val) { $qry='insert into '.$table_name.' set '.$val; return $result = $this->query($qry); } #ÀμƮ set ÇÔ¼ö(auto_increment.°ªÀ» °¡Áö°í ¿Â´Ù.) function insertIdx($table_name,$val) { $qry='insert into '.$table_name.' set '.$val; return $result = $this->queryIdx($qry); } #¾÷µ¥ÀÌÆ®ÇÔ¼ö function update($table_name, $fields, $where ) { $qry='update '.$table_name.' set '.$fields.' '.$where; return $result = $this->query($qry); } #ÇÕ°èÇÔ¼ö function sum($table_name,$where="",$fields) { $qry = 'select sum('.$fields.') from '.$table_name.' '.$where; $result = $this->query($qry); $row = mysql_fetch_row($result); if(empty($row['0'])) return 0; return $row['0']; } #Å×À̺íÀÌ ÀÖ³ª ¾ø³ª Á¶»çÇÏ´Â ÇÔ¼ö function isTable($table_name) { $ret_value = FALSE; $result = mysql_list_tables($this->db_name,$this->connect); while($row = mysql_fetch_row($result)) { if($table_name == $row['0']) { $ret_value = TRUE; break; } } return $ret_value; } // ¸Þ¼¼Áö Ãâ·ÂÈÄ À̵¿ÇÏ´Â ÀÚ¹Ù½ºÅ©¸³Æ® function alertJavaGo($msg,$url) { echo "<script language='javascript'> alert('$msg'); location.replace('$url'); </script>"; exit(); } } ?>
|