129 $Config = explode(
"#" , $ConfigRow );
131 $this->Username =
$Config[ 1 ];
132 $this->Password =
$Config[ 2 ];
133 $this->Database =
$Config[ 3 ];
134 $this->TablenamePrefix =
$Config[ 4 ];
136 $this->Connection = mssql_pconnect( $this->Host , $this->Username , $this->Password );
137 mssql_select_db( $this->Database , $this->Connection );
139 catch( Exception $e )
167 if( $this->Connection ===
false || $ForceReconnect ===
true )
169 if( $this->Connection !==
false )
171 mssql_close( $this->Connection );
173 $DBConfigSet =
get_package(
'database::db_config_set' ,
'last' , __FILE__ );
174 $DBConfigSet->load_config( dirname( __FILE__ ).
'/conf/cf_mssql_database' );
175 $this->Connection = $DBConfigSet->connect( $this );
176 if( mssql_get_last_message() !==
false )
180 'An error occured while setting connection to the database '.mssql_get_last_message()
185 return( $this->Connection );
187 catch( Exception $e )
217 $Query = str_replace(
'umx_' , $this->TablenamePrefix , $Query );
223 throw(
new Exception(
'An error occured while query execution '.
$Connection->error ) );
228 catch( Exception $e )
256 self::$QueryMode = $theQueryMode;
258 catch( Exception $e )
294 function select( $What , $Tables , $Condition =
'1 = 1' )
298 $Result = $this->
query(
"SELECT $What FROM $Tables WHERE $Condition" );
302 catch( Exception $e )
334 $RetValues = array();
336 for( $i = 0; $i < $Result->num_rows ; $i++ )
340 $RetValues [] = $Result->fetch_array( MYSQLI_ASSOC );
344 $RetValues [] = $Result->fetch_object();
350 return( $RetValues );
352 catch( Exception $e )
384 function insert( $Table , $Fields , $Values )
388 $this->
query(
"INSERT INTO $Table ( $Fields ) VALUES ( $Values )" );
390 catch( Exception $e )
418 function delete( $Table , $Condition =
'1 = 1' )
422 $this->
query(
"DELETE FROM $Table WHERE $Condition" );
424 catch( Exception $e )
460 function update( $Table , $Fields , $Values , $Condition =
'1 = 1' )
466 for( $i = 0 ; $i < count( $Fields ) - 1 ; $i++ )
468 $SubQuery .= $Fields[ $i ].
' = '.$Values[ $i ].
' , ';
470 $SubQuery .= $Fields[ count( $Fields ) - 1 ].
' = '.$Values[ count( $Fields ) - 1 ];
472 $this->
query(
"UPDATE $Table SET $SubQuery WHERE $Condition" );
474 catch( Exception $e )
502 function create( $Table , $FirstIndexField =
'id' )
507 "CREATE TABLE `$Table` ( `$FirstIndexField` INTEGER UNSIGNED NOT NULL DEFAULT NULL ".
508 "AUTO_INCREMENT , PRIMARY KEY ( `$FirstIndexField` ) )"
511 catch( Exception $e )
539 $this->
query(
"DROP TABLE $Table" );
541 catch( Exception $e )
577 function add_column( $Table , $ColumnName , $Type , $Mode =
'NOT NULL AFTER `id`' )
581 $this->
query(
"ALTER TABLE `$Table` ADD COLUMN `$ColumnName` $Type $Mode" );
583 catch( Exception $e )
615 $this->
query(
"ALTER TABLE `$Table` DROP COLUMN `$ColumnName`" );
617 catch( Exception $e )
645 function lock( $Tables , $Modes )
649 throw(
new Exception(
"Table locking unavailable" ) );
651 catch( Exception $e )
675 throw(
new Exception(
"Table locking unavailable" ) );
677 catch( Exception $e )
705 $this->
query(
'SAVEPOINT '.$Savepoint );
707 catch( Exception $e )
735 $this->
query(
'ROLLBACK TO SAVEPOINT '.$Savepoint );
737 catch( Exception $e )
761 $this->
query(
'START TRANSACTION' );
763 catch( Exception $e )
787 $this->
query(
'COMMIT' );
789 catch( Exception $e )