ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields | Static Public Attributes
mssql_database_1_0_0 Class Reference

## Public Member Functions
| connect ($ConfigRow)
| get_connection ($ForceReconnect=false)
| query ($Query)
| query_as ($theQueryMode)
| select ($What, $Tables, $Condition= '1=1')
| fetch_results ($Result)
| insert ($Table, $Fields, $Values)
| delete ($Table, $Condition= '1=1')
| update ($Table, $Fields, $Values, $Condition= '1=1')
| create ($Table, $FirstIndexField= 'id')
| drop ($Table)
| add_column ($Table, $ColumnName, $Type, $Mode= 'NOT NULL AFTER`id`')
| drop_column ($Table, $ColumnName)
| lock ($Tables, $Modes)
| unlock ()
| savepoint ($Savepoint)
| rollback ($Savepoint)
| transaction ()
| commit ()

## Data Fields
| $Connection = false
| $Config = false
| $Host
| $Username
| $Password
| $Database
| $TablenamePrefix
| $DBLogging

## Static Public Attributes
static | $LockedTables = false
static | $LockModes = false
static | $QueryMode = DB_ASSOC_ARRAY

## Detailed Description

Class providees routine for database manipulation.

Author
  Dodonov A.A.

Definition at line 26 of file mssql_database.php.

## Member Function Documentation

add_column | ( |  | $Table,
|  |  | $ColumnName,
|  |  | $Type,
|  |  | $Mode = `'NOT NULL AFTER `id`'`
| ) |  |

Function inserts column in table.

Parameters

  $Table | - Name of the editig table (new column will be inserted).
  $ColumnName | - Name of the inserting column.
  $Type | - Type of the column.
  $Mode | - Column insertion mode.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 577 of file mssql_database.php.

{
try
{
$this->query( "ALTER TABLE `$Table` ADD COLUMN `$ColumnName` $Type $Mode" );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

commit | ( |  | ) |

Function commits transaction.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 783 of file mssql_database.php.

{
try
{
$this->query( 'COMMIT' );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

connect | ( |  | $ConfigRow | ) |

Function connects to database.

Parameters

  $ConfigRow | - String from the config.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 125 of file mssql_database.php.

{
try
{
$Config = explode( "#" , $ConfigRow );
$this->Host = $Config[ 0 ];
$this->Username = $Config[ 1 ];
$this->Password = $Config[ 2 ];
$this->Database = $Config[ 3 ];
$this->TablenamePrefix = $Config[ 4 ];
$this->Connection = mssql_pconnect( $this->Host , $this->Username , $this->Password );
mssql_select_db( $this->Database , $this->Connection );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

create | ( |  | $Table,
|  |  | $FirstIndexField = `'id'`
| ) |  |

Executes delete query.

Parameters

  $Table | - Created table.
  $FirstIndexField | - name of index field. Field will be created automatically.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 502 of file mssql_database.php.

{
try
{
$this->query(
"CREATE TABLE `$Table` ( `$FirstIndexField` INTEGER UNSIGNED NOT NULL DEFAULT NULL ".
"AUTO_INCREMENT , PRIMARY KEY ( `$FirstIndexField` ) )"
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

delete | ( |  | $Table,
|  |  | $Condition = `'1 = 1'`
| ) |  |

Executes delete query.

Parameters

  $Table | - Record (or records) will be deleted from this table.
  $Condition | - Record selection condition.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 418 of file mssql_database.php.

{
try
{
$this->query( "DELETE FROM $Table WHERE $Condition" );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

drop | ( |  | $Table | ) |

Executes delete table query.

Parameters

  $Table | - Deleted table.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 535 of file mssql_database.php.

{
try
{
$this->query( "DROP TABLE $Table" );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

drop_column | ( |  | $Table,
|  |  | $ColumnName
| ) |  |

Function deletes column from table.

Parameters

  $Table | - Name of the editig table (column will be deleted).
  $ColumnName | - Name of the deleting column.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 611 of file mssql_database.php.

{
try
{
$this->query( "ALTER TABLE `$Table` DROP COLUMN `$ColumnName`" );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

fetch_results | ( |  | $Result | ) |

Function fetches results of the query.

Parameters

  $Result | - query result object.

Returns
  Array of selected records.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 330 of file mssql_database.php.

{
try
{
$RetValues = array();
for( $i = 0; $i < $Result->num_rows ; $i++ )
{
if( self::$QueryMode == DB_ASSOC_ARRAY )
{
$RetValues [] = $Result->fetch_array( MYSQLI_ASSOC );
}
elseif( self::$QueryMode == DB_OBJECT )
{
$RetValues [] = $Result->fetch_object();
}
}
$Result->close();
return( $RetValues );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_connection | ( |  | $ForceReconnect = `false` | ) |

Function returns database connection.

Parameters

  $ForceReconnect | - Force reconnect to database.

Returns
  mysqli object.

Author
  Dodonov A.A.

Definition at line 163 of file mssql_database.php.

{
try
{
if( $this->Connection === false || $ForceReconnect ===true )
{
if( $this->Connection !== false )
{
mssql_close( $this->Connection );
}
$DBConfigSet = get_package( 'database::db_config_set' , 'last' , __FILE__ );
$DBConfigSet->load_config( dirname( __FILE__ ).'/conf/cf_mssql_database' );
$this->Connection = $DBConfigSet->connect( $this );
if( mssql_get_last_message() !== false )
{
throw(
new Exception(
'An error occured while setting connection to the database '.mssql_get_last_message()
)
);
}
}
return( $this->Connection );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

insert | ( |  | $Table,
|  |  | $Fields,
|  |  | $Values
| ) |  |

Executes insert query.

Parameters

  $Table | - New record will be inserted in this table.
  $Fields | - list of fields wich will be filled while record insertion.
  $Values | - field values.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 384 of file mssql_database.php.

{
try
{
$this->query( "INSERT INTO $Table ( $Fields ) VALUES ( $Values )" );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

lock | ( |  | $Tables,
|  |  | $Modes
| ) |  |

Function blocks tables.

Parameters

  $Tables | - Tables to block.
  $Modes | - Blocking modes.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 645 of file mssql_database.php.

{
try
{
throw( new Exception( "Table locking unavailable" ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

query | ( |  | $Query | ) |

Function executes query.

Parameters

  $Query | - query string.

Returns
  Query result.

Author
  Dodonov A.A.

Definition at line 211 of file mssql_database.php.

{
try
{
$Connection = $this->get_connection();
$Query = str_replace( 'umx_' , $this->TablenamePrefix , $Query );
$Result = $Connection->query( $Query );
if( $Connection->errno !== 0 )
{
throw( new Exception( 'An error occured while query execution '.$Connection->error ) );
}
return( $Result );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

query_as | ( |  | $theQueryMode | ) |

Mode of extracting data from table.

Parameters

  $theQueryMode | - either DB_ASSOC_ARRAY or DB_OBJECT.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 252 of file mssql_database.php.

{
try
{
self::$QueryMode = $theQueryMode;
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

rollback | ( |  | $Savepoint | ) |

Function rollbacks transaction to savepoint.

Parameters

  $Savepoint | - savepoint.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 731 of file mssql_database.php.

{
try
{
$this->query( 'ROLLBACK TO SAVEPOINT '.$Savepoint );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

savepoint | ( |  | $Savepoint | ) |

Function sets savepoint.

Parameters

  $Savepoint | - savepoint.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 701 of file mssql_database.php.

{
try
{
$this->query( 'SAVEPOINT '.$Savepoint );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

select | ( |  | $What,
|  |  | $Tables,
|  |  | $Condition = `'1 = 1'`
| ) |  |

Function executes select query.

Parameters

  $What | - List of selecting fields.
  $Tables | - List of tables to select data.
  $Condition | - Condition for records filtering.

Returns
  Array of selected records.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 294 of file mssql_database.php.

{
try
{
$Result = $this->query( "SELECT $What FROM $Tables WHERE $Condition" );
return( $this->fetch_results( $Result ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

transaction | ( |  | ) |

Function starts new transaction.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 757 of file mssql_database.php.

{
try
{
$this->query( 'START TRANSACTION' );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

unlock | ( |  | ) |

Function releases all locks for all tables.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 671 of file mssql_database.php.

{
try
{
throw( new Exception( "Table locking unavailable" ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

update | ( |  | $Table,
|  |  | $Fields,
|  |  | $Values,
|  |  | $Condition = `'1 = 1'`
| ) |  |

Executes update query.

Parameters

  $Table | - Record (or records) will be updated in this table.
  $Fields | - list of fields wich will be filled while record update.
  $Values | - field values.
  $Condition | - Record selection condition.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 460 of file mssql_database.php.

{
try
{
$SubQuery = '';
for( $i = 0 ; $i < count( $Fields ) - 1 ; $i++ )
{
$SubQuery .= $Fields[ $i ].' = '.$Values[ $i ].' , ';
}
$SubQuery .= $Fields[ count( $Fields ) - 1 ].' = '.$Values[ count( $Fields ) - 1 ];
$this->query( "UPDATE $Table SET $SubQuery WHERE $Condition" );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Field Documentation

$Config = false

Config.

Author
  Додонов А.А.

Definition at line 88 of file mssql_database.php.

$Connection = false

Connection object.

Author
  Dodonov A.A.

Definition at line 38 of file mssql_database.php.

$Database

Definition at line 103 of file mssql_database.php.

$DBLogging

Definition at line 105 of file mssql_database.php.

$Host

DB connection parameters.

Author
  Dodonov A.A.

Definition at line 100 of file mssql_database.php.

$LockedTables = false
| static

List pf blocked tables.

Author
  Dodonov A.A.

Definition at line 50 of file mssql_database.php.

$LockModes = false
| static

Lock modes.

Author
  Dodonov A.A.

Definition at line 62 of file mssql_database.php.

$Password

Definition at line 102 of file mssql_database.php.

$QueryMode = DB_ASSOC_ARRAY
| static

Data querying mode. Either DB_ASSOC_ARRAY (record is reprecented as associative array) or DB_OBJECT (record is represented as an object).

Author
  Dodonov A.A.

Definition at line 76 of file mssql_database.php.

$TablenamePrefix

Definition at line 104 of file mssql_database.php.

$Username

Definition at line 101 of file mssql_database.php.

The documentation for this class was generated from the following file:

- packages/database/packages/mssql_database/mssql_database.php