Absolut Engine PHP Cross Reference Web Portal Systems

Source: /admin/classdb.php - 68 lines - 1842 bytes - Summary - Text - Print

   1  <?
   2  /**

   3   * @package absolutengine

   4   */
   5  /** Class for accessing the MySQL database

   6   */
   7  class CDatabase
   8  {
   9  
  10     function CDatabase()
  11     {
  12     // do nothing

  13     }
  14  
  15     /** Connects to the database

  16      * @access public

  17      */
  18     function DBConnect()
  19     {
  20     @$this->connection=mysql_connect($this->dbserver,$this->dbuser,$this->dbpass);
  21     if (!$this->connection) $this->DisplayError(3);
  22     mysql_select_db($this->dbname);
  23     }
  24  
  25     /** Queries the database

  26      * @access public

  27      * @param string query SQL query to execute

  28      * when INSERT command is used, $this->insertID is set to ID of inserted element

  29      * when SELECT command is used, $this->rowsnumber is set to number of returned rows

  30      * when UPDATE/DELETE command is used, $this->rowsnumber is set to number of affected rows

  31      */
  32     function DBQuery($query)
  33     {
  34     @$this->outcome=mysql_query($query,$this->connection);
  35     $errormessage=mysql_error();
  36     if ($errormessage=="") $errormessage="SUCCESS";
  37     $this->PrintDebugText($errormessage." for ".$query);
  38     if (!$this->outcome)
  39        {
  40        $this->DisplayError(2,1);
  41        }
  42     $this->insertID=mysql_insert_id(); // gets insertID to use later

  43     if (substr($query,0,6)=="SELECT") $this->rowsnumber=mysql_num_rows($this->outcome); // gets number of rows selected to use later

  44     else $this->rowsnumber=mysql_affected_rows(); // gets number of rows affected to use later

  45     }
  46  
  47     /** Alias function to DBGetRow() for backward compatibility

  48      * @access public

  49      * @deprecated since 1.70

  50      * @see DBGetRow()

  51      */
  52     function DBAccess()
  53     {
  54     return $this->DBGetRow();
  55     }
  56  
  57     /** Retrieve one row from query

  58      * @access public

  59      * @see DBQuery()

  60      */
  61     function DBGetRow()
  62     {
  63     return $this->access=mysql_fetch_array($this->outcome);
  64     }
  65  
  66  }
  67  
  68  ?>

title

Description

title

Description

title

Description

title

title

Body