ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields
db_config_set_1_0_0 Class Reference

## Public Member Functions
| __construct ()
| load_config ($ConfigPath)
| optimize_config_file ($i, $ConfigLine)
| get_connection_for_config_line ($DBAdapter, $i, $ConfigLine)
| connect ($DBAdapter)

## Data Fields
| $Config = false
| $ConfigPath = false
| $CachedMultyFS = false

## Detailed Description

Class provides connection creation routine.

Author
  Dodonov A.A.

Definition at line 26 of file db_config_set.php.

## Constructor & Destructor Documentation

__construct | ( |  | ) |

Constructor.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 78 of file db_config_set.php.

{
try
{
$this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Member Function Documentation

connect | ( |  | $DBAdapter | ) |

Function connects to database.

Parameters

  $DBAdapter | - Database API adapter.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 241 of file db_config_set.php.

{
try
{
if( $this->Config == false )
{
throw( new Exception( 'Config was not loaded' ) );
}
foreach( $this->Config as $i => $ConfigLine )
{
$Connection = $this->get_connection_for_config_line( $DBAdapter , $i , $ConfigLine );
if( $Connection !== false )
{
return( $Connection );
}
}
throw( new Exception( "Unable to connect to the database" ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_connection_for_config_line | ( |  | $DBAdapter,
|  |  | $i,
|  |  | $ConfigLine
| ) |  |

Function processes config line.

Parameters

  $DBAdapter | - Database adapter.
  $i | - Line cursor.
  $ConfigLine | - Config line.

Returns
  Connection object.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 202 of file db_config_set.php.

{
try
{
if( $ConfigLine != '' )
{
$DBAdapter->connect( $ConfigLine );
$this->optimize_config_file( $i , $ConfigLine );
return( $DBAdapter->get_connection() );
}
return( false );
}
catch( Exception $e )
{
return( false );
}
}

load_config | ( |  | $ConfigPath | ) |

Function loads config.

Parameters

  $ConfigPath | - Path to the loading conig.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 108 of file db_config_set.php.

{
try
{
$this->Config = $this->CachedMultyFS->file_get_contents( $ConfigPath );
$this->Config = str_replace( "\r" , "\n" , $this->Config );
$this->Config = str_replace( "\n\n" , "\n" , $this->Config );
$this->Config = explode( "\n" , $this->Config );
$this->ConfigPath = $ConfigPath;
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

optimize_config_file | ( |  | $i,
|  |  | $ConfigLine
| ) |  |

Config optimization.

Parameters

  $i | - Line cursor.
  $DBAdapter | - Config line.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 148 of file db_config_set.php.

{
try
{
if( $i != 0 )
{
$Content = $ConfigLine."\r\n";
foreach( $this->Config as $j => $ConfigLine2 )
{
if( $i != $j && $ConfigLine2 != '' )
{
$Content .= $ConfigLine2."\r\n";
}
}
$this->Config = $this->CachedMultyFS->file_put_contents( $this->ConfigPath , $Content );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Field Documentation

$CachedMultyFS = false

Object provides access to the FS.

Author
  Dodonov A.A.

Definition at line 62 of file db_config_set.php.

$Config = false

Loaded config.

Author
  Dodonov A.A.

Definition at line 38 of file db_config_set.php.

$ConfigPath = false

Path to the loaded config.

Author
  Dodonov A.A.

Definition at line 50 of file db_config_set.php.

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

- packages/database/packages/db_config_set/db_config_set.php