16 define(
'DB_ASSOC_ARRAY' , 1 );
17 define(
'DB_OBJECT' , 2 );
130 $Config = explode(
"#" , $ConfigRow );
132 $this->Username =
$Config[ 1 ];
133 $this->Password =
$Config[ 2 ];
134 $this->Database =
$Config[ 3 ];
135 $this->TablenamePrefix =
$Config[ 4 ];
137 $this->Connection = @oci_pconnect( $this->Username , $this->Password );
139 catch( Exception $e )
167 if( $this->Connection ===
false || $ForceReconnect ===
true )
169 if( $this->Connection !==
false )
171 oci_close( $this->Connection );
173 $DBConfigSet =
get_package(
'database::db_config_set' ,
'last' , __FILE__ );
174 $DBConfigSet->load_config( dirname( __FILE__ ).
'/conf/cf_mysql_database' );
175 $this->Connection = $DBConfigSet->connect( $this );
176 if( oci_error() !==
false )
180 'An error occured while setting connection to the database '.$Error[
'message' ]
185 return( $this->Connection );
187 catch( Exception $e )
217 $Query = str_replace(
'umx_' , $this->TablenamePrefix , $Query );
220 oci_execute( $Stmt );
222 if( ( $Error = oci_error() ) !==
false )
224 throw(
new Exception(
'An error occured while query execution '.$Error[
'message' ] ) );
229 catch( Exception $e )
257 self::$QueryMode = $theQueryMode;
259 catch( Exception $e )
295 function select( $What , $Tables , $Condition =
'1 = 1' )
299 $Result = $this->
query(
"SELECT $What FROM $Tables WHERE $Condition" );
303 catch( Exception $e )
335 $RetValues = array();
337 for( $i = 0; $i < $Result->num_rows ; $i++ )
341 $RetValues [] = $Result->fetch_array( MYSQLI_ASSOC );
345 $RetValues [] = $Result->fetch_object();
351 return( $RetValues );
353 catch( Exception $e )
385 function insert( $Table , $Fields , $Values )
389 $this->
query(
"INSERT INTO $Table ( $Fields ) VALUES ( $Values )" );
391 catch( Exception $e )
419 function delete( $Table , $Condition =
'1 = 1' )
423 $this->
query(
"DELETE FROM $Table WHERE $Condition" );
425 catch( Exception $e )
461 function update( $Table , $Fields , $Values , $Condition =
'1 = 1' )
467 for( $i = 0 ; $i < count( $Fields ) - 1 ; $i++ )
469 $SubQuery .= $Fields[ $i ].
' = '.$Values[ $i ].
' , ';
471 $SubQuery .= $Fields[ count( $Fields ) - 1 ].
' = '.$Values[ count( $Fields ) - 1 ];
473 $this->
query(
"UPDATE $Table SET $SubQuery WHERE $Condition" );
475 catch( Exception $e )
503 function create( $Table , $FirstIndexField =
'id' )
508 "CREATE TABLE `$Table` ( `$FirstIndexField` INTEGER UNSIGNED NOT NULL DEFAULT ".
509 "NULL AUTO_INCREMENT , PRIMARY KEY ( `$FirstIndexField` ) )"
512 catch( Exception $e )
540 $this->
query(
"DROP TABLE $Table" );
542 catch( Exception $e )
578 function add_column( $Table , $ColumnName , $Type , $Mode =
'NOT NULL AFTER `id`' )
582 $this->
query(
"ALTER TABLE `$Table` ADD COLUMN `$ColumnName` $Type $Mode" );
584 catch( Exception $e )
616 $this->
query(
"ALTER TABLE `$Table` DROP COLUMN `$ColumnName`" );
618 catch( Exception $e )
646 function lock( $Tables , $Modes )
650 throw(
new Exception(
"Table locking unavailable" ) );
652 catch( Exception $e )
676 throw(
new Exception(
"Table locking unavailable" ) );
678 catch( Exception $e )
706 $this->
query(
'SAVEPOINT '.$Savepoint );
708 catch( Exception $e )
738 catch( Exception $e )
762 $this->
query(
'START TRANSACTION' );
764 catch( Exception $e )
790 catch( Exception $e )