home *** CD-ROM | disk | FTP | other *** search
- Simple Oracle Class
-
-
-
- <?
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // ORACLE CLASS BY ROCKTRON CHOI (highgain@unitel.co.kr) 2000,03,27
- // Digital UNIX, Apache1.3.9, PHP3.0.7
- //
- // Oracle Class have only 4 function(ExecSQL, Fetch, ColumnName, Close)
- // Setting only ORACLE_UID, PRACLE_PASS
- //
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- class Oracle
- {
- var $ORA_CON;
- var $ORA_DB;
- var $CON_CHECK = FALSE;
- var $ORA_UID = "ORACLE_UID";
- var $ORA_PASS = "ORACLE_PASS";
- var $Error;
- var $ErrorCode;
- var $FetchCount = 0;
- var $ColumCount = 0;
-
- //////////////////////////////////////////////////////////////////////////////////////////////////////////
- // DBConnect, Pase Query, Exec Query, Setting ColumCount
- function ExecSQL($Query)
- {
- if( $this->CON_CHECK == FALSE )
- {
- $this->ORA_CON = ora_logon($this->ORA_UID, $this->ORA_PASS);
- $this->ORA_DB = ora_open($this->ORA_CON);
- if( Ora_ErrorCode($this->ORA_DB) != 0 )
- {
- $this->Error = Ora_Error($this->ORA_DB);
- $this->ErrorCode = Ora_ErrorCode($this->ORA_DB);
- return FALSE;
- }
- $this->CON_CHECK = TRUE;
- }
- ora_parse($this->ORA_DB, $Query);
- if( ora_exec($this->ORA_DB) == FALSE )
- {
- $this->Error = Ora_Error($this->ORA_DB);
- $this->ErrorCode = Ora_ErrorCode($this->ORA_DB);
- return FALSE;
- }
- $this->ColumCount = ora_numcols($this->ORA_DB);
- return TRUE;
- }
-
- //////////////////////////////////////////////////////////////////////////////////////////////////////////
- // Fetch Record
- function Fetch()
- {
- $i=0;
- if( !ora_fetch($this->ORA_DB) )
- {
- $this->Error = Ora_Error($this->ORA_DB);
- $this->ErrorCode = Ora_ErrorCode($this->ORA_DB);
- return $FALSE;
- }
-
- for($i=0;$i<$this->ColumCount;$i++)
- {
- $FiledName1 = strtoupper(Ora_ColumnName($this->ORA_DB, $i));
- $FiledName2 = strtolower(Ora_ColumnName($this->ORA_DB, $i));
- $DATA = ora_getcolumn($this->ORA_DB, $i);
- $RECORD[ "$FiledName1"] = $DATA;
- $RECORD[ "$FiledName2"] = $DATA;
- $RECORD[$i] = $DATA;
- }
- return $RECORD;
- }
-
- //////////////////////////////////////////////////////////////////////////////////////////////////////////
- // return ColumnName
- function ColumnName($Count)
- {
- return Ora_ColumnName($this->ORA_DB, $Count);
- }
-
- //////////////////////////////////////////////////////////////////////////////////////////////////////////
- // Close Oracle
- function Close()
- {
- return ora_close($this->ORA_DB);
- }
- }
-
- /************************************************************************************************************
- SAMPLE CODE
- Oracle Class filename is ORACLE.INC, used by require
- *************************************************************************************************************
-
- require "ORACLE.INC";
-
- $RS = new Oracle;
- $RS2 = new Oracle;
-
- $RS->ExecSQL("SELECT USERNAME, ZIPCODE, ADDR FROM USER WHERE USERID='$USERID'" AND PASSWD='$PASSWD');
- if( ($DATA=$RS->Fetch()) == FALSE )
- {
- $ERROR_MSG = $RS->Error;
- $ERROR_CODE = $RS->ErrorCode;
- echo(" ($ERROR_CODE:$ERROR_MSG) ");
- exit;
- }
-
- $USERNAME = $DATA["USERNAME"];
- $ZIPCODE = $DATA["zipcode"];
- $ADDR = $DATA[2];
-
- echo("
- USERNAME: $USERNAME <BR>
- ZIPCODE : $ZIPCODE <BR>
- ADDRESS : $ADDRESS <BR>
- ");
-
- $RS2->ExecSQL("INSERT INTO LOGIN (USERID, LOGINTIME) VALUES ('$USERID',SYSDATE)");
- $RS2->ExecSQL("COMMIT");
-
- $RS2->Close();
- $RS->Close();
-
- *************************************************************************************************************/
-
- ?>
-