MDB2_Schema
[ class tree: MDB2_Schema ] [ index: MDB2_Schema ] [ all elements ]

Class: MDB2_Schema

Source Location: /MDB2_Schema-0.4.0/MDB2/Schema.php

Class Overview

PEAR
   |
   --MDB2_Schema

The database manager is a class that provides a set of database management services like installing, altering and dumping the data structures of databases.


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 78]
The database manager is a class that provides a set of database management services like installing, altering and dumping the data structures of databases.


[ Top ]


Class Variables

$database_definition = array(
        'name' => '',
        'create' => false,
        'tables' => array())

[line 91]


Type:   mixed


[ Top ]

$db =

[line 82]


Type:   mixed


[ Top ]

$options = array(
        'fail_on_invalid_names' => true,
        'dtd_file' => false,
    )

[line 86]


Type:   mixed


[ Top ]

$warnings = array()

[line 84]


Type:   mixed


[ Top ]



Method Detail

alterDatabase   [line 1512]

mixed alterDatabase( array $changes, [array $current_definition = null])

Execute the necessary actions to implement the requested changes in a database structure.
  • Return: MDB2_OK on success, or a MDB2 error object
  • Access: public

Parameters:

array   $changes     an associative array that contains the definition of the changes that are meant to be applied to the database structure.
array   $current_definition     multi dimensional array that contains the current definition

[ Top ]

alterDatabaseIndexes   [line 1319]

mixed alterDatabaseIndexes( string $table_name, array $changes)

Execute the necessary actions to implement the requested changes in the indexes inside a database structure.
  • Return: MDB2_OK on success, or a MDB2 error object
  • Access: public

Parameters:

array   $changes     an associative array that contains the definition of the changes that are meant to be applied to the database structure.
string   $table_name     name of the table

[ Top ]

alterDatabaseSequences   [line 1455]

mixed alterDatabaseSequences( array $changes, array $current_definition)

Execute the necessary actions to implement the requested changes in the sequences inside a database structure.
  • Return: MDB2_OK on success, or a MDB2 error object
  • Access: public

Parameters:

array   $changes     an associative array that contains the definition of the changes that are meant to be applied to the database structure.
array   $current_definition     multi dimensional array that contains the current definition

[ Top ]

alterDatabaseTables   [line 1382]

mixed alterDatabaseTables( array $changes, array $current_definition)

Execute the necessary actions to implement the requested changes in the tables inside a database structure.
  • Return: MDB2_OK on success, or a MDB2 error object
  • Access: public

Parameters:

array   $changes     an associative array that contains the definition of the changes that are meant to be applied to the database structure.
array   $current_definition     multi dimensional array that contains the current definition

[ Top ]

apiVersion   [line 106]

string apiVersion( )

Return the MDB2 API version
  • Return: the MDB2 API version number
  • Access: public

[ Top ]

compareDefinitions   [line 863]

mixed compareDefinitions( array $previous_definition, [array $current_definition = null])

compare a previous definition with the currenlty parsed definition
  • Return: array of changes on success, or a MDB2 error object
  • Access: public

Parameters:

array   $previous_definition     multi dimensional array that contains the previous definition
array   $current_definition     multi dimensional array that contains the current definition

[ Top ]

compareSequenceDefinitions   [line 1184]

mixed compareSequenceDefinitions( array $sequence_name, array $previous_definition, mixed $current_definition, mixed &$defined_sequences)

compare a previous definition with the currenlty parsed definition
  • Return: array of changes on success, or a MDB2 error object
  • Access: public

Parameters:

array   $sequence_name     multi dimensional array that contains the previous definition
array   $previous_definition     multi dimensional array that contains the current definition

[ Top ]

compareTableDefinitions   [line 1087]

mixed compareTableDefinitions( string $table_name, array $previous_definition, array $current_definition, mixed &$defined_tables)

compare a previous definition with the currenlty parsed definition
  • Return: array of changes on success, or a MDB2 error object
  • Access: public

Parameters:

string   $table_name     name of the table
array   $previous_definition     multi dimensional array that contains the previous definition
array   $current_definition     multi dimensional array that contains the current definition

[ Top ]

compareTableFieldsDefinitions   [line 934]

mixed compareTableFieldsDefinitions( string $table_name, array $previous_definition, array $current_definition, mixed &$defined_fields)

compare a previous definition with the currenlty parsed definition
  • Return: array of changes on success, or a MDB2 error object
  • Access: public

Parameters:

string   $table_name     name of the table
array   $previous_definition     multi dimensional array that contains the previous definition
array   $current_definition     multi dimensional array that contains the current definition

[ Top ]

compareTableIndexesDefinitions   [line 999]

mixed compareTableIndexesDefinitions( string $table_name, array $previous_definition, array $current_definition, mixed &$defined_indexes)

compare a previous definition with the currenlty parsed definition
  • Return: array of changes on success, or a MDB2 error object
  • Access: public

Parameters:

string   $table_name     name of the table
array   $previous_definition     multi dimensional array that contains the previous definition
array   $current_definition     multi dimensional array that contains the current definition

[ Top ]

connect   [line 232]

mixed connect( mixed &$db, [mixed $options = array()])

Create a new MDB2 connection object and connect to the specified database
  • Return: MDB2_OK on success, or a MDB2 error object
  • See: MDB2::parseDSN
  • Access: public

Parameters:

mixed   $db     'data source name', see the MDB2::parseDSN method for a description of the dsn format. Can also be specified as an array of the format returned by MDB2::parseDSN. Finally you can also pass an existing db object to be used.
mixed   $options     An associative array of option names and their values.

[ Top ]

createDatabase   [line 739]

mixed createDatabase( )

Create a database space within which may be created database objects

like tables, indexes and sequences. The implementation of this function is highly DBMS specific and may require special permissions to run successfully. Consult the documentation or the DBMS drivers that you use to be aware of eventual configuration requirements.

  • Return: MDB2_OK on success, or a MDB2 error object
  • Access: public

[ Top ]

createSequence   [line 655]

mixed createSequence( string $sequence_name, array $sequence, [boolean $overwrite = false])

create a sequence
  • Return: MDB2_OK on success, or a MDB2 error object
  • Access: public

Parameters:

string   $sequence_name     name of the sequence to be created
array   $sequence     multi dimensional array that containts the structure and optional data of the table
boolean   $overwrite     determine if the sequence should be overwritten

[ Top ]

createTable   [line 547]

mixed createTable( string $table_name, array $table, [boolean $overwrite = false])

create a table and inititialize the table if data is available
  • Return: MDB2_OK on success, or a MDB2 error object
  • Access: public

Parameters:

string   $table_name     name of the table to be created
array   $table     multi dimensional array that containts the structure and optional data of the table
boolean   $overwrite     determine if the table/index should be

[ Top ]

createTableIndexes   [line 460]

mixed createTableIndexes( string $table_name, array $indexes, [boolean $overwrite = false])

create a indexes om a table
  • Return: MDB2_OK on success, or a MDB2 error object
  • Access: public

Parameters:

string   $table_name     name of the table
array   $indexes     indexes to be created
boolean   $overwrite     determine if the table/index should be

[ Top ]

disconnect   [line 269]

void disconnect( )

Log out and disconnect from the database.
  • Access: public

[ Top ]

dumpDatabase   [line 1756]

mixed dumpDatabase( array $arguments, [integer $dump = MDB2_SCHEMA_DUMP_ALL])

Dump a previously parsed database structure in the Metabase schema XML based format suitable for the Metabase parser. This function may optionally dump the database definition with initialization commands that specify the data that is currently present in the tables.
  • Return: MDB2_OK on success, or a MDB2 error object
  • Access: public

Parameters:

array   $arguments     an associative array that takes pairs of tag names and values that define dump options. array ( 'definition' => Boolean true : dump currently parsed definition default: dump currently connected database 'output_mode' => String 'file' : dump into a file default: dump using a function 'output' => String depending on the 'Output_Mode' name of the file name of the function 'end_of_line' => String end of line delimiter that should be used default: "\n" );
integer   $dump     constant that determines what data to dump MDB2_SCHEMA_DUMP_ALL : the entire db MDB2_SCHEMA_DUMP_STRUCTURE : only the structure of the db MDB2_SCHEMA_DUMP_CONTENT : only the content of the db

[ Top ]

dumpDatabaseChanges   [line 1585]

mixed dumpDatabaseChanges( array $changes)

Dump the changes between two database definitions.
  • Return: MDB2_OK on success, or a MDB2 error object
  • Access: public

Parameters:

array   $changes     an associative array that specifies the list of database definitions changes as returned by the _compareDefinitions manager class function.

[ Top ]

errorMessage   [line 2027]

string errorMessage( int $value)

Return a textual error message for a MDB2_Schema error code
  • Return: error message, or false if the error code was not recognized
  • Access: public

Parameters:

int   $value     error code

[ Top ]

factory   [line 203]

mixed &factory( mixed &$db, [mixed $options = array()])

Create a new MDB2 object for the specified database type type
  • Return: MDB2_OK on success, or a MDB2 error object
  • See: MDB2::parseDSN
  • Access: public

Parameters:

mixed   $db     'data source name', see the MDB2::parseDSN method for a description of the dsn format. Can also be specified as an array of the format returned by MDB2::parseDSN. Finally you can also pass an existing db object to be used.
mixed   $options     An associative array of option names and their values.

[ Top ]

getDefinitionFromDatabase   [line 334]

mixed getDefinitionFromDatabase( )

Attempt to reverse engineer a schema structure from an existing MDB2 This method can be used if no xml schema file exists yet.

The resulting xml schema file may need some manual adjustments.

  • Return: MDB2_OK or array with all ambiguities on success, or a MDB2 error object
  • Access: public

[ Top ]

getOption   [line 175]

mixed getOption( string $option)

returns the value of an option
  • Return: the option value or error object
  • Access: public

Parameters:

string   $option     option name

[ Top ]

getWarnings   [line 135]

array getWarnings( )

get all warnings in reverse order.

This means that the last warning is the first element in the array


[ Top ]

initializeTable   [line 607]

mixed initializeTable( string $table_name, array $table)

inititialize the table with data
  • Return: MDB2_OK on success, or a MDB2 error object
  • Access: public

Parameters:

string   $table_name     name of the table
array   $table     multi dimensional array that containts the structure and optional data of the table

[ Top ]

isError   [line 2095]

bool isError( mixed $data, [int $code = null])

Tell whether a value is a MDB2_Schema error.
  • Return: true if parameter is an error
  • Access: public

Parameters:

mixed   $data     the value to test
int   $code     if $data is an error object, return true only if $code is a string and $db->getMessage() == $code or $code is an integer and $db->getCode() == $code

[ Top ]

parseDatabaseDefinitionFile   [line 293]

mixed parseDatabaseDefinitionFile( string $input_file, [array $variables = array()], [bool $fail_on_invalid_names = true], [mixed $structure = false])

Parse a database definition file by creating a Metabase schema format parser object and passing the file contents as parser input data stream.
  • Return: MDB2_OK on success, or a MDB2 error object
  • Access: public

Parameters:

string   $input_file     the path of the database schema file.
array   $variables     an associative array that the defines the text string values that are meant to be used to replace the variables that are used in the schema description.
bool   $fail_on_invalid_names     (optional) make function fail on invalid names

[ Top ]

raiseError   [line 2075]

object a &raiseError( [mixed $code = null], [int $mode = null], [mixed $options = null], [string $userinfo = null])

This method is used to communicate an error and invoke error callbacks etc. Basically a wrapper for PEAR::raiseError without the message string.
  • Return: PEAR error object
  • See: PEAR_Error

Parameters:

mixed   $code     integer error code
int   $mode     error mode, see PEAR_Error docs
mixed   $options     If error mode is PEAR_ERROR_TRIGGER, this is the error level (E_USER_NOTICE etc). If error mode is PEAR_ERROR_CALLBACK, this is the callback function, either as a function name, or as an array of an object and method name. For other error modes this parameter is ignored.
string   $userinfo     Extra debug information. Defaults to the last query and native error code.

[ Top ]

resetWarnings   [line 119]

void resetWarnings( )

reset the warning array
  • Access: public

[ Top ]

setOption   [line 151]

mixed setOption( string $option, mixed $value)

set the option for the db class
  • Return: MDB2_OK or MDB2 Error Object
  • Access: public

Parameters:

string   $option     option name
mixed   $value     value for the option

[ Top ]

updateDatabase   [line 1928]

mixed updateDatabase( mixed $current_schema, [mixed $previous_schema = false], [array $variables = array()], [bool $disable_query = false])

Compare the correspondent files of two versions of a database schema definition: the previously installed and the one that defines the schema that is meant to update the database.

If the specified previous definition file does not exist, this function will create the database from the definition specified in the current schema file. If both files exist, the function assumes that the database was previously installed based on the previous schema file and will update it by just applying the changes. If this function succeeds, the contents of the current schema file are copied to replace the previous schema file contents. Any subsequent schema changes should only be done on the file specified by the $current_schema_file to let this function make a consistent evaluation of the exact changes that need to be applied.

  • Return: MDB2_OK on success, or a MDB2 error object
  • Access: public

Parameters:

mixed   $current_schema     filename or array of the updated database schema definition.
mixed   $previous_schema     filename or array of the previously installed database schema definition.
array   $variables     an associative array that is passed to the argument of the same name to the parseDatabaseDefinitionFile function. (there third param)
bool   $disable_query     determines if the disable_query option should be set to true for the alterDatabase() or createDatabase() call

[ Top ]

verifyAlterDatabase   [line 1250]

mixed verifyAlterDatabase( array $changes)

verify that the changes requested are supported
  • Return: MDB2_OK on success, or a MDB2 error object
  • Access: public

Parameters:

array   $changes     an associative array that contains the definition of the changes that are meant to be applied to the database structure.

[ Top ]

writeInitialization   [line 1825]

mixed writeInitialization( string $data_file, [string $structure_file = false], [array $variables = array()])

write initialization and sequences
  • Return: MDB2_OK on success, or a MDB2 error object
  • Access: public

Parameters:

string   $data_file     
string   $structure_file     
array   $variables     an associative array that is passed to the argument of the same name to the parseDatabaseDefinitionFile function. (there third param)

[ Top ]


Documentation generated on Wed, 21 Dec 2005 06:33:16 -0500 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.