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

mysql.php

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


 001  <?php
 002  /***************************************************************************
 003   *                                 mysql.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","mysql");
 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   
 036      //
 037      // Constructor
 038      //
 039      function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
 040      {
 041   
 042          $this->persistency = $persistency;
 043          $this->user = $sqluser;
 044          $this->password = $sqlpassword;
 045          $this->server = $sqlserver;
 046          $this->dbname = $database;
 047   
 048          if($this->persistency)
 049          {
 050              $this->db_connect_id = @mysql_pconnect($this->server, $this->user, $this->password);
 051          }
 052          else
 053          {
 054              $this->db_connect_id = @mysql_connect($this->server, $this->user, $this->password);
 055          }
 056          if($this->db_connect_id)
 057          {
 058              if($database != "")
 059              {
 060                  $this->dbname = $database;
 061                  $dbselect = @mysql_select_db($this->dbname);
 062                  if(!$dbselect)
 063                  {
 064                      @mysql_close($this->db_connect_id);
 065                      $this->db_connect_id = $dbselect;
 066                  }
 067              }
 068              return $this->db_connect_id;
 069          }
 070          else
 071          {
 072              return false;
 073          }
 074      }
 075   
 076      //
 077      // Other base methods
 078      //
 079      function sql_close()
 080      {
 081          if($this->db_connect_id)
 082          {
 083              if($this->query_result)
 084              {
 085                  @mysql_free_result($this->query_result);
 086              }
 087              $result = @mysql_close($this->db_connect_id);
 088              return $result;
 089          }
 090          else
 091          {
 092              return false;
 093          }
 094      }
 095   
 096      //
 097      // Base query method
 098      //
 099      function sql_query($query = "", $transaction = FALSE)
 100      {
 101          // Remove any pre-existing queries
 102          unset($this->query_result);
 103          if($query != "")
 104          {
 105              $this->num_queries++;
 106   
 107              $this->query_result = @mysql_query($query, $this->db_connect_id);
 108          }
 109          if($this->query_result)
 110          {
 111              unset($this->row[$this->query_result]);
 112              unset($this->rowset[$this->query_result]);
 113              return $this->query_result;
 114          }
 115          else
 116          {
 117              return ( $transaction == END_TRANSACTION ) ? true : false;
 118          }
 119      }
 120   
 121      //
 122      // Other query methods
 123      //
 124      function sql_numrows($query_id = 0)
 125      {
 126          if(!$query_id)
 127          {
 128              $query_id = $this->query_result;
 129          }
 130          if($query_id)
 131          {
 132              $result = @mysql_num_rows($query_id);
 133              return $result;
 134          }
 135          else
 136          {
 137              return false;
 138          }
 139      }
 140      function sql_affectedrows()
 141      {
 142          if($this->db_connect_id)
 143          {
 144              $result = @mysql_affected_rows($this->db_connect_id);
 145              return $result;
 146          }
 147          else
 148          {
 149              return false;
 150          }
 151      }
 152      function sql_numfields($query_id = 0)
 153      {
 154          if(!$query_id)
 155          {
 156              $query_id = $this->query_result;
 157          }
 158          if($query_id)
 159          {
 160              $result = @mysql_num_fields($query_id);
 161              return $result;
 162          }
 163          else
 164          {
 165              return false;
 166          }
 167      }
 168      function sql_fieldname($offset, $query_id = 0)
 169      {
 170          if(!$query_id)
 171          {
 172              $query_id = $this->query_result;
 173          }
 174          if($query_id)
 175          {
 176              $result = @mysql_field_name($query_id, $offset);
 177              return $result;
 178          }
 179          else
 180          {
 181              return false;
 182          }
 183      }
 184      function sql_fieldtype($offset, $query_id = 0)
 185      {
 186          if(!$query_id)
 187          {
 188              $query_id = $this->query_result;
 189          }
 190          if($query_id)
 191          {
 192              $result = @mysql_field_type($query_id, $offset);
 193              return $result;
 194          }
 195          else
 196          {
 197              return false;
 198          }
 199      }
 200      function sql_fetchrow($query_id = 0)
 201      {
 202          if(!$query_id)
 203          {
 204              $query_id = $this->query_result;
 205          }
 206          if($query_id)
 207          {
 208              $this->row[$query_id] = @mysql_fetch_array($query_id);
 209              return $this->row[$query_id];
 210          }
 211          else
 212          {
 213              return false;
 214          }
 215      }
 216      function sql_fetchrowset($query_id = 0)
 217      {
 218          if(!$query_id)
 219          {
 220              $query_id = $this->query_result;
 221          }
 222          if($query_id)
 223          {
 224              unset($this->rowset[$query_id]);
 225              unset($this->row[$query_id]);
 226              while($this->rowset[$query_id] = @mysql_fetch_array($query_id))
 227              {
 228                  $result[] = $this->rowset[$query_id];
 229              }
 230              return $result;
 231          }
 232          else
 233          {
 234              return false;
 235          }
 236      }
 237      function sql_fetchfield($field, $rownum = -1, $query_id = 0)
 238      {
 239          if(!$query_id)
 240          {
 241              $query_id = $this->query_result;
 242          }
 243          if($query_id)
 244          {
 245              if($rownum > -1)
 246              {
 247                  $result = @mysql_result($query_id, $rownum, $field);
 248              }
 249              else
 250              {
 251                  if(empty($this->row[$query_id]) && empty($this->rowset[$query_id]))
 252                  {
 253                      if($this->sql_fetchrow())
 254                      {
 255                          $result = $this->row[$query_id][$field];
 256                      }
 257                  }
 258                  else
 259                  {
 260                      if($this->rowset[$query_id])
 261                      {
 262                          $result = $this->rowset[$query_id][0][$field];
 263                      }
 264                      else if($this->row[$query_id])
 265                      {
 266                          $result = $this->row[$query_id][$field];
 267                      }
 268                  }
 269              }
 270              return $result;
 271          }
 272          else
 273          {
 274              return false;
 275          }
 276      }
 277      function sql_rowseek($rownum, $query_id = 0){
 278          if(!$query_id)
 279          {
 280              $query_id = $this->query_result;
 281          }
 282          if($query_id)
 283          {
 284              $result = @mysql_data_seek($query_id, $rownum);
 285              return $result;
 286          }
 287          else
 288          {
 289              return false;
 290          }
 291      }
 292      function sql_nextid(){
 293          if($this->db_connect_id)
 294          {
 295              $result = @mysql_insert_id($this->db_connect_id);
 296              return $result;
 297          }
 298          else
 299          {
 300              return false;
 301          }
 302      }
 303      function sql_freeresult($query_id = 0){
 304          if(!$query_id)
 305          {
 306              $query_id = $this->query_result;
 307          }
 308   
 309          if ( $query_id )
 310          {
 311              unset($this->row[$query_id]);
 312              unset($this->rowset[$query_id]);
 313   
 314              @mysql_free_result($query_id);
 315   
 316              return true;
 317          }
 318          else
 319          {
 320              return false;
 321          }
 322      }
 323      function sql_error($query_id = 0)
 324      {
 325          $result["message"] = @mysql_error($this->db_connect_id);
 326          $result["code"] = @mysql_errno($this->db_connect_id);
 327   
 328          return $result;
 329      }
 330   
 331  } // class sql_db
 332   
 333  } // if ... define
 334   
 335  ?>