質問編集履歴

1

変更

2015/05/08 03:05

投稿

bh_C
bh_C

スコア31

test CHANGED
File without changes
test CHANGED
@@ -10,10 +10,120 @@
10
10
 
11
11
  <?php
12
12
 
13
-
14
-
15
13
  //データベースクラス
16
14
 
15
+ class DB
16
+
17
+ {
18
+
19
+ public $Connect;
20
+
21
+
22
+
23
+ // コンストラクタ
24
+
25
+ function DB($Server='localhost', $DbName='test', $User='yoshizawa', $Password='')
26
+
27
+ {
28
+
29
+ $this->Connect = mysql_connect($Server, $User, $Password);
30
+
31
+ mysql_select_db($DbName, $this->Connect);
32
+
33
+ }
34
+
35
+
36
+
37
+ // 接続解除
38
+
39
+ function Close()
40
+
41
+ {
42
+
43
+ mysql_close($this->Connect);
44
+
45
+ }
46
+
47
+
48
+
49
+ // クエリーの実行
50
+
51
+ function Query($SqlQuery)
52
+
53
+ {
54
+
55
+ $ret = mysql_query($SqlQuery, $this->Connect);
56
+
57
+ return $ret;
58
+
59
+ }
60
+
61
+
62
+
63
+ // クエリーの実行結果の取得(配列)
64
+
65
+ function fetch($result)
66
+
67
+ {
68
+
69
+ return mysql_fetch_array($result);
70
+
71
+ }
72
+
73
+
74
+
75
+ // クエリーの実行と結果の取得
76
+
77
+ function QueryEx($SqlQuery='')
78
+
79
+ {
80
+
81
+ if ($SqlQuery!='')
82
+
83
+ {
84
+
85
+ $result = $this->Query($SqlQuery);
86
+
87
+ if (!$result)
88
+
89
+ {
90
+
91
+ return false;
92
+
93
+ }
94
+
95
+ return $this->fetch($result);
96
+
97
+ }
98
+
99
+ else
100
+
101
+ {
102
+
103
+ return false;
104
+
105
+ }
106
+
107
+ }
108
+
109
+ }
110
+
111
+ ?>
112
+
113
+ ```
114
+
115
+
116
+
117
+
118
+
119
+ ```lang-<PHP>
120
+
121
+ <?php
122
+
123
+
124
+
125
+ //データベースクラス
126
+
17
127
  class DB {
18
128
 
19
129
  var $Connect;
@@ -109,111 +219,3 @@
109
219
  }
110
220
 
111
221
  ```
112
-
113
-
114
-
115
-
116
-
117
- ```lang-<PHP>
118
-
119
- <?php
120
-
121
-
122
-
123
- //データベースクラス
124
-
125
- class DB {
126
-
127
- var $Connect;
128
-
129
- var $Result;
130
-
131
- var $Debug;
132
-
133
-
134
-
135
- // コンストラクタ
136
-
137
- function DB( $Server='localhost', $DbName='test', $User='yoshizawa', $Password='' ) {
138
-
139
- $this->Connect = mysql_connect( $Server, $User, $Password );
140
-
141
- mysql_select_db( $DbName, $this->Connect );
142
-
143
- $this->Debug = FALSE;
144
-
145
- }
146
-
147
-
148
-
149
- // 接続解除
150
-
151
- function Close( ) {
152
-
153
- mysql_close( $this->Connect );
154
-
155
- }
156
-
157
-
158
-
159
- //クエリー
160
-
161
- function Query( $SqlQuery ) {
162
-
163
- $ret = mysql_query( $SqlQuery,$this->Connect );
164
-
165
- if ( $this->Debug ) {
166
-
167
- if ( mysql_errno() != 0 ) {
168
-
169
- print "<B>" . mysql_error() . "</B><BR>";
170
-
171
- }
172
-
173
- }
174
-
175
- return $ret;
176
-
177
- }
178
-
179
-
180
-
181
- // フェッチ
182
-
183
- function Fetch( $Result ) {
184
-
185
- return mysql_fetch_array( $Result );
186
-
187
- }
188
-
189
-
190
-
191
- // クエリーとフェッチ
192
-
193
- function QueryEx( $SqlQuery='' ) {
194
-
195
-
196
-
197
- if ( $SqlQuery != '' ) {
198
-
199
- $this->Result = $this->Query( $SqlQuery );
200
-
201
- if ( !$this->Result ) {
202
-
203
- return FALSE;
204
-
205
- }
206
-
207
- return $this->Fetch ( $this->Result );
208
-
209
- }
210
-
211
- else {
212
-
213
- return $this->Fetch ( $this->Result );
214
-
215
- }
216
-
217
- }
218
-
219
- ```