发信人: bb_rain() 
整理人: tang(2001-01-31 09:00:37), 站内信件
 | 
 
 
<?
 
 /********************************************************************* *********
 
     Data Module for PHP3 & PHP4  ( Database, v 1.00 )
 
     Copyright (C) 2000 heyin.com, All Rights Reserved.
                        http://www.heyin.com
                        Rain ( Email: [email protected]  Oicq: 1235686 )
 
     cl_data.php, 2000/8/26
 
 ********************************************************************** *********/
 
 
 include $PATH."database/db_config.php";
 include $PATH."database/db_mysql.php";
 
 /*
   Change Database Type -
     db_mysql.php                         //  MySQL
     db_mssql.php                         //  SQL Server ( Windows NT ) 
     db_sybase.php                        //  Sybase
     db_odbc.php                          //  ODBC
     db_ora.php                           //  ORACLE
     db_oci8.php                          //  ORACLE 8
 */
 
 
 //  Data Module Class
 
 class DataModule extends DBModule {
 
   var $TABLE_NAME;
   var $IN;
   var $SUB;
 
   //  Create Data Module
   function Create($TableName) {
     $this->DBModule();
     $this->TABLE_NAME = $TableName;
   }
 
   //  Set Value
   function Set($varname,$value) {
     $this->$varname=$value;
   }
 
   //  Insert Data
   function Add() {
     $SQL="SELECT * FROM ".$this->TABLE_NAME;
     $this->Query($SQL);
     $this->dbFieldName();                //  Return Field Name Array
 
     $count=count($this->FD_NAME);
     for ($i=0;$i<$count;$i++) { $FD_VALUE[$i]="''"; }
 
     while ( list($key, $val) = each($this->IN) ) {
       for ($i=0;$i<$count;$i++) {
         if ($this->FD_NAME[$i]==$key) $FD_VALUE[$i]="'".$val."'";
       }
     }
 
     $FD_NAME = implode(',',$this->FD_NAME);
     $VALUE_LIST = implode(',',$FD_VALUE);
 
     $SQL="INSERT INTO ".$this->TABLE_NAME." (".$FD_NAME.") VALUES (".$ VALUE_LIST.")";
     $this->Query($SQL);
 
     unset($this->FD_NAME);               //  Clear Field Name Array
   }
 
   //  Update Data
   function Edit() {
     $count=count($this->IN);
     for ($i=0;$i<$count;$i++) {
       list($key,$val) = each($this->IN);
       $FD_VALUE[$i] = $key."='".$val."'";
     }
 
     $VALUE_LIST = implode(',',$FD_VALUE);
 
     $SQL="UPDATE ".$this->TABLE_NAME." SET ".$VALUE_LIST." ".$this->SU B;
     $this->Query($SQL);
 
     unset($this->SUB);                   //  Clear Sub
   }
 
   //  Read Data
   function Read() {
     global $OUT,$COUNT,$LINES;
 
     $SQL="SELECT * FROM ".$this->TABLE_NAME." ".$this->SUB;
 
     $this->Query($SQL);
     $this->dbNumRows();
 
     $COUNT = $this->COUNT;               //  Return $COUNT
 
     for ($i=0;$i<$COUNT;$i++) {
       $this->dbFetchArray();
       $LINES[$i]=$this->LINES;           //  Return $LINES
     }
 
     $OUT = $LINES[0];                    //  Return $OUT
 
     unset($this->SUB);                   //  Clear Sub
   }
 
   //  Delete Data
   function Del() {
     $SQL="DELETE FROM ".$this->TABLE_NAME." ".$this->SUB;
     $this->Query($SQL);
 
     unset($this->SUB);                   //  Clear Sub
   }
 
   //  Return $TOTAL
   function Total() {
     global $TOTAL;
 
     $SQL="SELECT Count(*) AS total FROM ".$this->TABLE_NAME." ".$this- >SUB;
     $this->Query($SQL);
 
     $this->dbFetchArray();
     $TOTAL = $this->LINES['total'];
 
     unset($this->SUB);                   //  Clear Sub
   }
 }
 
 ?>
  -- HEYIN 软件 http://www.heyin.com  
 虚拟社区,聊天室,交友程序,网上超市,电子商务 ...
  ※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 61.133.178.72]
  | 
 
 
 |