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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

msaccess.php

Zuletzt modifiziert: 09.10.2024, 12:51 - Dateigröße: 8.27 KiB


001  <?php
002  /***************************************************************************
003   *                               msaccess.php
004   *                            -------------------
005   *   begin                : Saturday, Feb 13, 2001
006   *   copyright            : (C) 2001 The phpBB Group
007   *   email                : support@phpbb.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","msaccess");
026   
027  class sql_db
028  {
029   
030      var $db_connect_id;
031      var $result_ids = array();
032      var $result;
033   
034      var $next_id;
035   
036      var $num_rows = array();
037      var $current_row = array();
038      var $field_names = array();
039      var $field_types = array();
040      var $result_rowset = array();
041   
042      var $num_queries = 0;
043   
044      //
045      // Constructor
046      //
047      function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
048      {
049          $this->persistency = $persistency;
050          $this->server = $sqlserver;
051          $this->user = $sqluser;
052          $this->password = $sqlpassword;
053          $this->dbname = $database;
054   
055          $this->db_connect_id = ($this->persistency) ? odbc_pconnect($this->server, $this->user, $this->password) : odbc_connect($this->server, $this->user, $this->password);
056   
057          return ( $this->db_connect_id ) ? $this->db_connect_id : false;
058      }
059      //
060      // Other base methods
061      //
062      function sql_close()
063      {
064          if($this->db_connect_id)
065          {
066              if( $this->in_transaction )
067              {
068                  @odbc_commit($this->db_connect_id);
069              }
070   
071              if( count($this->result_rowset) )
072              {
073                  unset($this->result_rowset);
074                  unset($this->field_names);
075                  unset($this->field_types);
076                  unset($this->num_rows);
077                  unset($this->current_row);
078              }
079   
080              return @odbc_close($this->db_connect_id);
081          }
082          else
083          {
084              return false;
085          }
086      }
087   
088      //
089      // Query method
090      //
091      function sql_query($query = "", $transaction = FALSE)
092      {
093          if( $query != "" )
094          {
095              $this->num_queries++;
096   
097              if( $transaction == BEGIN_TRANSACTION && !$this->in_transaction )
098              {
099                  if( !odbc_autocommit($this->db_connect_id, false) )
100                  {
101                      return false;
102                  }
103                  $this->in_transaction = TRUE;
104              }
105   
106              $query = str_replace("LOWER(", "LCASE(", $query);
107   
108              if( preg_match("/^SELECT(.*?)(LIMIT ([0-9]+)[, ]*([0-9]+)*)?$/s", $query, $limits) )
109              {
110                  $query = $limits[1];
111   
112                  if( !empty($limits[2]) )
113                  {
114                      $row_offset = ( $limits[4] ) ? $limits[3] : "";
115                      $num_rows = ( $limits[4] ) ? $limits[4] : $limits[3];
116   
117                      $query = "TOP " . ( $row_offset + $num_rows ) . $query;
118                  }
119   
120                  $this->result = odbc_exec($this->db_connect_id, "SELECT $query");
121   
122                  if( $this->result )
123                  {
124                      if( empty($this->field_names[$this->result]) )
125                      {
126                          for($i = 1; $i < odbc_num_fields($this->result) + 1; $i++)
127                          {
128                              $this->field_names[$this->result][] = odbc_field_name($this->result, $i);
129                              $this->field_types[$this->result][] = odbc_field_type($this->result, $i);
130                          }
131                      }
132   
133                      $this->current_row[$this->result] = 0;
134                      $this->result_rowset[$this->result] = array();
135   
136                      $row_outer = ( isset($row_offset) ) ? $row_offset + 1 : 1;
137                      $row_outer_max = ( isset($num_rows) ) ? $row_offset + $num_rows + 1 : 1E9;
138                      $row_inner = 0;
139   
140                      while( odbc_fetch_row($this->result, $row_outer) && $row_outer < $row_outer_max )
141                      {
142                          for($j = 0; $j < count($this->field_names[$this->result]); $j++)
143                          {
144                              $this->result_rowset[$this->result][$row_inner][$this->field_names[$this->result][$j]] = stripslashes(odbc_result($this->result, $j + 1));
145                          }
146   
147                          $row_outer++;
148                          $row_inner++;
149                      }
150   
151                      $this->num_rows[$this->result] = count($this->result_rowset[$this->result]);
152   
153                      odbc_free_result($this->result);
154                  }
155   
156              }
157              else if( eregi("^INSERT ", $query) )
158              {
159                  $this->result = odbc_exec($this->db_connect_id, $query);
160   
161                  if( $this->result )
162                  {
163                      $result_id = odbc_exec($this->db_connect_id, "SELECT @@IDENTITY");
164                      if( $result_id )
165                      {
166                          if( odbc_fetch_row($result_id) )
167                          {
168                              $this->next_id[$this->db_connect_id] = odbc_result($result_id, 1);
169                              $this->affected_rows[$this->db_connect_id] = odbc_num_rows($this->result);
170                          }
171                      }
172                  }
173              }
174              else
175              {
176                  $this->result = odbc_exec($this->db_connect_id, $query);
177   
178                  if( $this->result )
179                  {
180                      $this->affected_rows[$this->db_connect_id] = odbc_num_rows($this->result);
181                  }
182              }
183   
184              if( !$this->result )
185              {
186                  if( $this->in_transaction )
187                  {
188                      odbc_rollback($this->db_connect_id);
189                      odbc_autocommit($this->db_connect_id, true);
190                      $this->in_transaction = FALSE;
191                  }
192   
193                  return false;
194              }
195   
196              if( $transaction == END_TRANSACTION && $this->in_transaction )
197              {
198                  $this->in_transaction = FALSE;
199   
200                  if ( !@odbc_commit($this->db_connect_id) )
201                  {
202                      odbc_rollback($this->db_connect_id);
203                      odbc_autocommit($this->db_connect_id, true);
204                      return false;
205                  }
206                  odbc_autocommit($this->db_connect_id, true);
207              }
208   
209              return $this->result;
210          }
211          else
212          {
213              if( $transaction == END_TRANSACTION && $this->in_transaction )
214              {
215                  $this->in_transaction = FALSE;
216   
217                  if ( !@odbc_commit($this->db_connect_id) )
218                  {
219                      odbc_rollback($this->db_connect_id);
220                      odbc_autocommit($this->db_connect_id, true);
221                      return false;
222                  }
223                  odbc_autocommit($this->db_connect_id, true);
224              }
225   
226              return true;
227          }
228      }
229   
230      //
231      // Other query methods
232      //
233      function sql_numrows($query_id = 0)
234      {
235          if( !$query_id )
236          {
237              $query_id = $this->result;
238          }
239   
240          return ( $query_id ) ? $this->num_rows[$query_id] : false;
241      }
242   
243      function sql_numfields($query_id = 0)
244      {
245          if( !$query_id )
246          {
247              $query_id = $this->result;
248          }
249   
250          return ( $query_id ) ? count($this->field_names[$query_id]) : false;
251      }
252   
253      function sql_fieldname($offset, $query_id = 0)
254      {
255          if( !$query_id )
256          {
257              $query_id = $this->result;
258          }
259   
260          return ( $query_id ) ? $this->field_names[$query_id][$offset] : false;
261      }
262   
263      function sql_fieldtype($offset, $query_id = 0)
264      {
265          if( !$query_id )
266          {
267              $query_id = $this->result;
268          }
269   
270          return ( $query_id ) ? $this->field_types[$query_id][$offset] : false;
271      }
272   
273      function sql_fetchrow($query_id = 0)
274      {
275          if( !$query_id )
276          {
277              $query_id = $this->result;
278          }
279   
280          if( $query_id )
281          {
282              return ( $this->num_rows[$query_id] && $this->current_row[$query_id] < $this->num_rows[$query_id] ) ? $this->result_rowset[$query_id][$this->current_row[$query_id]++] : false;
283          }
284          else
285          {
286              return false;
287          }
288      }
289   
290      function sql_fetchrowset($query_id = 0)
291      {
292          if( !$query_id )
293          {
294              $query_id = $this->result;
295          }
296   
297          if( $query_id )
298          {
299              return ( $this->num_rows[$query_id] ) ? $this->result_rowset[$query_id] : false;
300          }
301          else
302          {
303              return false;
304          }
305      }
306   
307      function sql_fetchfield($field, $row = -1, $query_id = 0)
308      {
309          if( !$query_id )
310          {
311              $query_id = $this->result;
312          }
313   
314          if( $query_id )
315          {
316              if( $row < $this->num_rows[$query_id] )
317              {
318                  $getrow = ($row == -1) ? $this->current_row[$query_id] - 1 : $row;
319   
320                  return $this->result_rowset[$query_id][$getrow][$this->field_names[$query_id][$field]];
321              }
322              else
323              {
324                  return false;
325              }
326          }
327          else
328          {
329              return false;
330          }
331      }
332   
333      function sql_rowseek($offset, $query_id = 0)
334      {
335          if( !$query_id )
336          {
337              $query_id = $this->result;
338          }
339   
340          if( $query_id )
341          {
342              $this->current_row[$query_id] = $offset - 1;
343              return true;
344          }
345          else
346          {
347              return false;
348          }
349      }
350   
351      function sql_nextid()
352      {
353          return ( $this->next_id[$this->db_connect_id] ) ? $this->next_id[$this->db_connect_id] : false;
354      }
355   
356      function sql_affectedrows()
357      {
358          return ( $this->affected_rows[$this->db_connect_id] ) ? $this->affected_rows[$this->db_connect_id] : false;
359      }
360   
361      function sql_freeresult($query_id = 0)
362      {
363          if( !$query_id )
364          {
365              $query_id = $this->result;
366          }
367   
368          unset($this->num_rows[$query_id]);
369          unset($this->current_row[$query_id]);
370          unset($this->result_rowset[$query_id]);
371          unset($this->field_names[$query_id]);
372          unset($this->field_types[$query_id]);
373   
374          return true;
375      }
376   
377      function sql_error()
378      {
379          $error['code'] = "";//odbc_error($this->db_connect_id);
380          $error['message'] = "Error";//odbc_errormsg($this->db_connect_id);
381   
382          return $error;
383      }
384   
385  } // class sql_db
386   
387  } // if ... define
388   
389  ?>