Verzeichnisstruktur phpBB-2.0.0
- Veröffentlicht
- 03.04.2002
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
mysql4.php
001 <?php
002 /***************************************************************************
003 * mysql4.php
004 * -------------------
005 * begin : Saturday, Feb 13, 2001
006 * copyright : (C) 2001 The phpBB Group
007 * email : supportphpbb.com
008 *
009 * $Id$
010 *
011 ***************************************************************************/
012
013 /***************************************************************************
014 *
015 * This program is free software; you can redistribute it and/or modify
016 * it under the terms of the GNU General Public License as published by
017 * the Free Software Foundation; either version 2 of the License, or
018 * (at your option) any later version.
019 *
020 ***************************************************************************/
021
022 if(!defined("SQL_LAYER"))
023 {
024
025 define("SQL_LAYER","mysql4");
026
027 class sql_db
028 {
029
030 var $db_connect_id;
031 var $query_result;
032 var $row = array();
033 var $rowset = array();
034 var $num_queries = 0;
035 var $in_transaction = 0;
036
037 //
038 // Constructor
039 //
040 function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
041 {
042 $this->persistency = $persistency;
043 $this->user = $sqluser;
044 $this->password = $sqlpassword;
045 $this->server = $sqlserver;
046 $this->dbname = $database;
047
048 $this->db_connect_id = ($this->persistency) ? mysql_pconnect($this->server, $this->user, $this->password) : mysql_connect($this->server, $this->user, $this->password);
049
050 if( $this->db_connect_id )
051 {
052 if( $database != "" )
053 {
054 $this->dbname = $database;
055 $dbselect = mysql_select_db($this->dbname);
056
057 if( !$dbselect )
058 {
059 mysql_close($this->db_connect_id);
060 $this->db_connect_id = $dbselect;
061 }
062 }
063
064 return $this->db_connect_id;
065 }
066 else
067 {
068 return false;
069 }
070 }
071
072 //
073 // Other base methods
074 //
075 function sql_close()
076 {
077 if( $this->db_connect_id )
078 {
079 //
080 // Commit any remaining transactions
081 //
082 if( $this->in_transaction )
083 {
084 mysql_query("COMMIT", $this->db_connect_id);
085 }
086
087 return mysql_close($this->db_connect_id);
088 }
089 else
090 {
091 return false;
092 }
093 }
094
095 //
096 // Base query method
097 //
098 function sql_query($query = "", $transaction = FALSE)
099 {
100 //
101 // Remove any pre-existing queries
102 //
103 unset($this->query_result);
104
105 if( $query != "" )
106 {
107 $this->num_queries++;
108 if( $transaction == BEGIN_TRANSACTION && !$this->in_transaction )
109 {
110 $result = mysql_query("BEGIN", $this->db_connect_id);
111 if(!$result)
112 {
113 return false;
114 }
115 $this->in_transaction = TRUE;
116 }
117
118 $this->query_result = mysql_query($query, $this->db_connect_id);
119 }
120 else
121 {
122 if( $transaction == END_TRANSACTION && $this->in_transaction )
123 {
124 $result = mysql_query("COMMIT", $this->db_connect_id);
125 }
126 }
127
128 if( $this->query_result )
129 {
130 unset($this->row[$this->query_result]);
131 unset($this->rowset[$this->query_result]);
132
133 if( $transaction == END_TRANSACTION && $this->in_transaction )
134 {
135 $this->in_transaction = FALSE;
136
137 if ( !mysql_query("COMMIT", $this->db_connect_id) )
138 {
139 mysql_query("ROLLBACK", $this->db_connect_id);
140 return false;
141 }
142 }
143
144 return $this->query_result;
145 }
146 else
147 {
148 if( $this->in_transaction )
149 {
150 mysql_query("ROLLBACK", $this->db_connect_id);
151 $this->in_transaction = FALSE;
152 }
153 return false;
154 }
155 }
156
157 //
158 // Other query methods
159 //
160 function sql_numrows($query_id = 0)
161 {
162 if( !$query_id )
163 {
164 $query_id = $this->query_result;
165 }
166
167 return ( $query_id ) ? mysql_num_rows($query_id) : false;
168 }
169
170 function sql_affectedrows()
171 {
172 return ( $this->db_connect_id ) ? mysql_affected_rows($this->db_connect_id) : false;
173 }
174
175 function sql_numfields($query_id = 0)
176 {
177 if( !$query_id )
178 {
179 $query_id = $this->query_result;
180 }
181
182 return ( $query_id ) ? mysql_num_fields($query_id) : false;
183 }
184
185 function sql_fieldname($offset, $query_id = 0)
186 {
187 if( !$query_id )
188 {
189 $query_id = $this->query_result;
190 }
191
192 return ( $query_id ) ? mysql_field_name($query_id, $offset) : false;
193 }
194
195 function sql_fieldtype($offset, $query_id = 0)
196 {
197 if( !$query_id )
198 {
199 $query_id = $this->query_result;
200 }
201
202 return ( $query_id ) ? mysql_field_type($query_id, $offset) : false;
203 }
204
205 function sql_fetchrow($query_id = 0)
206 {
207 if( !$query_id )
208 {
209 $query_id = $this->query_result;
210 }
211
212 if( $query_id )
213 {
214 $this->row[$query_id] = mysql_fetch_array($query_id, MYSQL_ASSOC);
215 return $this->row[$query_id];
216 }
217 else
218 {
219 return false;
220 }
221 }
222
223 function sql_fetchrowset($query_id = 0)
224 {
225 if( !$query_id )
226 {
227 $query_id = $this->query_result;
228 }
229
230 if( $query_id )
231 {
232 unset($this->rowset[$query_id]);
233 unset($this->row[$query_id]);
234
235 while($this->rowset[$query_id] = mysql_fetch_array($query_id, MYSQL_ASSOC))
236 {
237 $result[] = $this->rowset[$query_id];
238 }
239
240 return $result;
241 }
242 else
243 {
244 return false;
245 }
246 }
247
248 function sql_fetchfield($field, $rownum = -1, $query_id = 0)
249 {
250 if( !$query_id )
251 {
252 $query_id = $this->query_result;
253 }
254
255 if( $query_id )
256 {
257 if( $rownum > -1 )
258 {
259 $result = mysql_result($query_id, $rownum, $field);
260 }
261 else
262 {
263 if( empty($this->row[$query_id]) && empty($this->rowset[$query_id]) )
264 {
265 if( $this->sql_fetchrow() )
266 {
267 $result = $this->row[$query_id][$field];
268 }
269 }
270 else
271 {
272 if( $this->rowset[$query_id] )
273 {
274 $result = $this->rowset[$query_id][0][$field];
275 }
276 else if( $this->row[$query_id] )
277 {
278 $result = $this->row[$query_id][$field];
279 }
280 }
281 }
282
283 return $result;
284 }
285 else
286 {
287 return false;
288 }
289 }
290
291 function sql_rowseek($rownum, $query_id = 0)
292 {
293 if( !$query_id )
294 {
295 $query_id = $this->query_result;
296 }
297
298 return ( $query_id ) ? mysql_data_seek($query_id, $rownum) : false;
299 }
300
301 function sql_nextid()
302 {
303 return ( $this->db_connect_id ) ? mysql_insert_id($this->db_connect_id) : false;
304 }
305
306 function sql_freeresult($query_id = 0)
307 {
308 if( !$query_id )
309 {
310 $query_id = $this->query_result;
311 }
312
313 if ( $query_id )
314 {
315 unset($this->row[$query_id]);
316 unset($this->rowset[$query_id]);
317
318 mysql_free_result($query_id);
319
320 return true;
321 }
322 else
323 {
324 return false;
325 }
326 }
327
328 function sql_error()
329 {
330 $result['message'] = mysql_error($this->db_connect_id);
331 $result['code'] = mysql_errno($this->db_connect_id);
332
333 return $result;
334 }
335
336 } // class sql_db
337
338 } // if ... define
339
340 ?>
341