ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields
db_settings_1_0_0 Class Reference

## Public Member Functions
| __construct ()
| unsafe_select ($Condition)
| create ($Record)
| get_setting ($SettingName, $DefaultValue= '_throw_exception')
| set_setting ($SettingName, $Value)
| __toString ()

## Data Fields
| $NativeTable = '`umx_setting`'
| $Database = false
| $DatabaseAlgorithms = false
| $Security = false
| $SecurityParser = false

## Detailed Description

Working with settings.

Author
  Dodonov A.A.

Definition at line 26 of file db_settings.php.

## Constructor & Destructor Documentation

__construct | ( |  | ) |

Constructor.

Author
  Dodonov A.A.

Definition at line 65 of file db_settings.php.

{
try
{
$this->Database = get_package( 'database' , 'last' , __FILE__ );
$this->DatabaseAlgorithms = get_package( 'database::database_algorithms' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
$this->SecurityParser = get_package( 'security::security_parser' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Member Function Documentation

__toString | ( |  | ) |

Function converts object to string.

Returns
  string with the object's description.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 288 of file db_settings.php.

{
try
{
return( serialize( $this->SettingsList ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

create | ( |  | $Record | ) |

Creating record.

Parameters

  $Record | Example for creation.

Returns
  id of the created record.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 140 of file db_settings.php.

{
try
{
$Record = $this->SecurityParser->parse_parameters( $Record , 'name:string;value:string' );
list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
$this->Database->lock( array( $this->NativeTable ) , array( 'WRITE' ) );
$this->Database->insert( $this->NativeTable , implode( ',' , $Fields ) , implode( ',' , $Values ) );
$this->Database->commit();
$id = $this->Database->select( '*' , $this->NativeTable , '1 = 1 ORDER by id DESC LIMIT 0 , 1' );
$id = get_field( $id[ 0 ] , 'id' );
$this->Database->unlock();
return( $id );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_setting | ( |  | $SettingName,
|  |  | $DefaultValue = `'_throw_exception'`
| ) |  |

Function provides access to the loaded settings.

Parameters

  $SettingName | - Setting title.
  $DefaultValue | - Default value for undefined setting.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 188 of file db_settings.php.

{
try
{
$SettingName = $this->Security->get( $SettingName , 'command' );
$Time = time();
$Settings = $this->unsafe_select(
"name LIKE '$SettingName' AND date_from <= $Time AND $Time <= date_to"
);
if( isset( $Settings[ 0 ] ) )
{
return( get_field( $Settings[ 0 ] , 'value' ) );
}
elseif( $DefaultValue === '_throw_exception' )
{
throw( new Exception( "Setting \"$SettingName\" was not found" ) );
}
else
{
return( $DefaultValue );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

set_setting | ( |  | $SettingName,
|  |  | $Value
| ) |  |

Function provides setting values for settings.

Parameters

  $SettingName | - Setting title.
  $Value | - Default value for setting.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 240 of file db_settings.php.

{
try
{
$SettingName = $this->Security->get( $SettingName , 'command' );
$Time = time();
$Settings = $this->unsafe_select(
"name LIKE '$SettingName' AND date_from <= $Time AND $Time <= date_to"
);
if( isset( $Settings[ 0 ] ) )
{
$id = get_field( $Settings[ 0 ] , 'id' );
$Chronological = get_package( 'database::chronological' , 'last' , __FILE__ );
$Chronological->update_record(
$id , array( 'name' => get_field( $Settings[ 0 ] , 'name' ) , 'value' => $Value ) , $this
);
}
else
{
throw( new Exception( "Setting \"$SettingName\" was not found" ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

unsafe_select | ( |  | $Condition | ) |

Selecting records.

Parameters

  $Condition | - Records selection condition.

Returns
  Array of objects.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 102 of file db_settings.php.

{
try
{
$this->Database->query_as( DB_OBJECT );
$Settings = $this->Database->select( '*' , $this->NativeTable , "$Condition" );
return( $Settings );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Field Documentation

$Database = false

Cache.

Author
  Dodonov A.A.

Definition at line 50 of file db_settings.php.

$DatabaseAlgorithms = false

Definition at line 51 of file db_settings.php.

$NativeTable = '`umx_setting`'

Table name.

Author
  Dodonov A.A.

Definition at line 38 of file db_settings.php.

$Security = false

Definition at line 52 of file db_settings.php.

$SecurityParser = false

Definition at line 53 of file db_settings.php.

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

- packages/settings/packages/db_settings/db_settings.php