ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields
dump_1_0_0 Class Reference

## Public Member Functions
| __construct ()
| get_list_of_tables ($DumpCreationConfig)
| get_drop_dump ($TableDumpCreationConfig, $TableName)
| get_fields_dump ($TableDumpCreationConfig, $TableName)
| get_auto_increment ($TableDumpCreationConfig, $TableName)
| get_create_dump ($TableDumpCreationConfig, $TableName)
| get_structure_dump ($TableDumpCreationConfig, $TableName)
| get_insert_dump ($TableName, &$Fields, &$Records)
| get_data_dump ($TableDumpCreationConfig, $TableName)
| get_dump_of_table ($TableName, &$DumpCreationConfig)
| get_dump ($DumpName)
| view ($Options)

## Data Fields
| $CachedMultyFS = false
| $Database = false
| $DatabaseAlgorithms = false
| $Security = false

## Detailed Description

Class provides DB dumps creation routine.

Author
  Dodonov A.A.

Definition at line 26 of file dump.php.

## Constructor & Destructor Documentation

__construct | ( |  | ) |

Constructor.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 57 of file dump.php.

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

## Member Function Documentation

get_auto_increment | ( |  | $TableDumpCreationConfig,
|  |  | $TableName
| ) |  |

Function returns a dump of the auto_increment.

Parameters

  $TableDumpCreationConfig | - Config for dump creation.
  $TableName | - Table's name.

Returns
  Autoincrement info.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 288 of file dump.php.

{
try
{
$TableName = $this->Security->get( $TableName , 'command' );
$Fields = $this->DatabaseAlgorithms->get_list_of_fields( $TableName );
foreach( $Fields as $i => $FieldInfo )
{
$Extra = get_field( $FieldInfo , 'Extra' );
if( $Extra == 'auto_increment' )
{
$FieldName = get_field( $FieldInfo , 'Field' );
$MaxValue = $this->Database->select( "MAX( $FieldName ) AS max_field_value" , "`$TableName`" );
$MaxValue = intval( get_field( $MaxValue[ 0 ] , 'max_field_value' ) ) + 1;
return( "AUTO_INCREMENT=$MaxValue" );
}
}
return( '' );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_create_dump | ( |  | $TableDumpCreationConfig,
|  |  | $TableName
| ) |  |

Function returns a dump for the specified table.

Parameters

  $TableDumpCreationConfig | - Config for dump creation.
  $TableName | - Table's name.

Returns
  Dump of the table.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 344 of file dump.php.

{
try
{
$TableName = $this->Security->get( $TableName , 'command' );
/* removing prefix */
$ClearTableName = str_replace(
array( $this->Database->TablenamePrefix , 'umx_' ) , array( '' , '' ) , $TableName
);
$Dump = "CREATE TABLE `[lfb]prefix[rfb]$ClearTableName` (\n";
$Dump .= $this->get_fields_dump( $TableDumpCreationConfig , $TableName );
$Encoding = $TableDumpCreationConfig->get_setting( 'encoding' , 'utf8' );
$Autoincrement = $this->get_auto_increment( $TableDumpCreationConfig , $TableName );
$Dump .= "\n) $Autoincrement DEFAULT CHARSET=$Encoding;\n\n";
return( $Dump );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_data_dump | ( |  | $TableDumpCreationConfig,
|  |  | $TableName
| ) |  |

Function returns a dump of data.

Parameters

  $TableDumpCreationConfig | - Config for dump creation.
  $TableName | - Table's name.

Returns
  Dump of the table.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 546 of file dump.php.

{
try
{
$Dump = '';
if( $TableDumpCreationConfig->get_setting( 'records' , false ) )
{
$Fields = get_field_ex( $this->DatabaseAlgorithms->get_list_of_fields( $TableName ) , 'Field' );
$Fields = '`'.implode( '` , `' , $Fields ).'`';
$this->Database->query_as( DB_ARRAY );
$Records = $this->Database->select( '*' , "`$TableName`" );
$Dump = $this->get_insert_dump( $TableName , $Fields , $Records );
}
return( $Dump );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_drop_dump | ( |  | $TableDumpCreationConfig,
|  |  | $TableName
| ) |  |

Function returns a dump for the specified table.

Parameters

  $TableDumpCreationConfig | - Config for dump creation.
  $TableName | - Table's name.

Returns
  Dump of the table.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 141 of file dump.php.

{
try
{
if( $TableDumpCreationConfig->get_setting( 'delete_existing' , false ) )
{
$TableName = $this->Security->get( $TableName , 'command' );
/* removing prefix */
$ClearTableName = str_replace(
array( $this->Database->TablenamePrefix , 'umx_' ) , array( '' , '' ) , $TableName
);
return( "DROP TABLE IF EXISTS `[lfb]prefix[rfb]$ClearTableName`;\n" );
}
else
{
return( '' );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_dump | ( |  | $DumpName | ) |

Function creates dump of the database.

Parameters

  $DumpName | - Name of the config.

Returns
  Dump of the database.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 640 of file dump.php.

{
try
{
$DumpCreationConfig = get_package_object( 'settings::settings' , 'last' , __FILE__ );
$DumpName = $this->Security->get( $DumpName , 'command' );
$DumpCreationConfig->load_file( dirname( __FILE__ )."/conf/$DumpName" , '#' );
$Dump = '';
$Tables = $this->get_list_of_tables( $DumpCreationConfig );
foreach( $Tables as $i => $TableName )
{
$Dump .= $this->get_dump_of_table( $TableName , $DumpCreationConfig );
}
return( rtrim( $Dump , "\n" ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_dump_of_table | ( |  | $TableName,
|  | & | $DumpCreationConfig
| ) |  |

Function returns a dump for the specified table.

Parameters

  $TableName | - Table's name.
  $DumpCreationConfig | - Dump creation config.

Returns
  Dump of the table.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 596 of file dump.php.

{
try
{
$DefaultConfig = 'records;structure;enecoding=utf8;delete_existing';
$TableDumpCreationConfig = get_package_object( 'settings::settings' , 'last' , __FILE__ );
$TableDumpCreationConfig->load_settings(
$DumpCreationConfig->get_setting( $TableName , $DefaultConfig )
);
$Dump = $this->get_structure_dump( $TableDumpCreationConfig , $TableName );
$Dump .= $this->get_data_dump( $TableDumpCreationConfig , $TableName );
return( $Dump );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_fields_dump | ( |  | $TableDumpCreationConfig,
|  |  | $TableName
| ) |  |

Function returns a dump of fields for the specified table.

Parameters

  $TableDumpCreationConfig | - Config for dump creation.
  $TableName | - Table's name.

Returns
  Dump of the table.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 242 of file dump.php.

{
try
{
$TableName = $this->Security->get( $TableName , 'command' );
$Fields = $this->DatabaseAlgorithms->get_list_of_fields( $TableName );
foreach( $Fields as $i => $FieldInfo )
{
$Fields[ $i ] = $this->get_field_script( $FieldInfo , $Fields );
}
return( implode( ",\n" , $Fields ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_insert_dump | ( |  | $TableName,
|  | & | $Fields,
|  | & | $Records
| ) |  |

Function returns a dump of data insertion command.

Parameters

  $TableName | - Table's name.
  $Fields | - Fields.
  $Records | - Records to be put in the dump.

Returns
  Dump of the table.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 489 of file dump.php.

{
try
{
$Dump = '';
if( isset( $Records[ 0 ] ) )
{
if( strpos( $TableName , $this->Database->TablenamePrefix ) === 0 )
{
$ClearTableName = substr( $TableName , strlen( $this->Database->TablenamePrefix ) );
}
$ClearTableName = str_replace( 'umx_' , '', $ClearTableName );
$Dump = "INSERT INTO `[lfb]prefix[rfb]$ClearTableName` ( $Fields ) VALUES \n";
foreach( $Records as $i => $Record )
{
$Records[ $i ] = $this->prepare_record( $Record );
}
$Dump .= implode( ",\n" , $Records ).";\n\n";
}
return( $Dump );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_list_of_tables | ( |  | $DumpCreationConfig | ) |

Function returns a list of tables.

Parameters

  $DumpCreationConfig | - Config for dump creation.

Returns
  A list of tables.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 94 of file dump.php.

{
try
{
$ListOfTables = $DumpCreationConfig->get_setting( 'tables' );
if( $ListOfTables === 'all' )
{
return( $this->DatabaseAlgorithms->get_list_of_tables() );
}
else
{
return( explode( ',' , $ListOfTables ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_structure_dump | ( |  | $TableDumpCreationConfig,
|  |  | $TableName
| ) |  |

Function returns a dump for the specified table.

Parameters

  $TableDumpCreationConfig | - Config for dump creation.
  $TableName | - Table's name.

Returns
  Dump of the table.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 396 of file dump.php.

{
try
{
if( $TableDumpCreationConfig->get_setting( 'delete_existing' , false ) )
{
$Dump = $this->get_drop_dump( $TableDumpCreationConfig , $TableName );
$Dump .= $this->get_create_dump( $TableDumpCreationConfig , $TableName );
return( $Dump );
}
else
{
return( '' );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

view | ( |  | $Options | ) |

Function draws component.

Parameters

  $Options | - Settings.

Returns
  HTML code of the компонента.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 685 of file dump.php.

{
try
{
if( $Options->get_setting( 'dump_settings_form' , 0 ) == 1 )
{
}
elseif( $Options->get_setting( 'dump' , 0 ) == 1 )
{
$Dump = $this->get_dump( 'full_dump' );
header( 'HTTP/1.0 200 OK' );
header( 'Content-type: application/octet-stream' );
header( "Content-Length: ".strlen( $Dump ) );
header( "Content-Disposition: attachment; filename=\"data.sql\"" );
header( 'Connection: close' );
return( $Dump );
}
else
{
return( '' );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Field Documentation

$CachedMultyFS = false

Cached packages.

Author
  Dodonov A.A.

Definition at line 38 of file dump.php.

$Database = false

Definition at line 39 of file dump.php.

$DatabaseAlgorithms = false

Definition at line 40 of file dump.php.

$Security = false

Definition at line 41 of file dump.php.

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

- packages/database/packages/dump/dump.php