Class adoSchema

Description

Loads and parses an XML file, creating an array of "ready-to-run" SQL statements

This class is used to load and parse the XML file, to create an array of SQL statements that can be used to build a database, and to build the database using the SQL array.

  • version: $Revision: 1.7 $
  • author: Richard Tango-Lowy & Dan Cech
  • tutorial: Getting Started

Located in /adodb-xmlschema.inc.php (line 1201)


	
			
Variable Summary
Method Summary
 adoSchema adoSchema (object &$db)
 bool ContinueOnError ([bool $mode = NULL])
 string ConvertSchemaFile (string $filename, [string $newVersion = NULL], [string $newFile = NULL])
 string ConvertSchemaString (string $schema, [string $newVersion = NULL], [string $newFile = NULL])
 void Destroy ()
 bool ExecuteInline ([bool $mode = NULL])
 integer ExecuteSchema ([array $sqlArray = NULL], [boolean $continueOnErr = NULL])
 string ExtractSchema ([boolean $data = FALSE])
 array ParseSchema (mixed $filename, [bool $returnSchema = FALSE], string $file)
 array ParseSchemaFile (mixed $filename, [bool $returnSchema = FALSE], string $file)
 array ParseSchemaString (string $xmlstring, [bool $returnSchema = FALSE])
 array PrintSQL ([string $format = 'NONE'])
 array RemoveSchema (mixed $filename, [bool $returnSchema = FALSE], string $file)
 array RemoveSchemaString (string $schema, [bool $returnSchema = FALSE])
 boolean SaveSQL ([string $filename = './schema.sql'])
 string SchemaFileVersion (string $filename)
 string SchemaStringVersion (string $xmlstring)
 boolean SetPrefix ([string $prefix = ''], [boolean $underscore = TRUE])
 string SetUpgradeMethod ([string $method = ''])
 void TransformSchema (mixed $schema, mixed $xsl, [mixed $schematype = 'string'])
Variables
bool $continueOnError (line 1276)
  • var: Continue SQL execution if errors occur
bool $executeInline (line 1271)
  • var: Execute SQL inline as it is generated
int $success (line 1266)
  • var: Success of last Schema execution
Methods
Constructor adoSchema (line 1287)

Creates an adoSchema object

Creating an adoSchema object is the first step in processing an XML schema. The only parameter is an ADOdb database connection object, which must already have been created.

adoSchema adoSchema (object &$db)
  • object $db: ADOdb database connection object.
ContinueOnError (line 1381)

Enables/disables SQL continue on error.

Call this method to enable or disable continuation of SQL execution if an error occurs. If the mode is set to TRUE (continue), AXMLS will continue to apply SQL to the database, even if an error occurs. If the mode is set to FALSE (halt), AXMLS will halt execution of generated sql if an error occurs, though parsing of the schema will continue.

bool ContinueOnError ([bool $mode = NULL])
  • bool $mode: execute
ConvertSchemaFile (line 1720)

Converts an XML schema file to the specified DTD version.

Call this method to convert the specified XML schema file to a different AXMLS DTD version. For instance, to convert a schema created for an pre-1.0 version for AXMLS (DTD version 0.1) to a newer version of the DTD (e.g. 0.2). If no DTD version parameter is specified, the schema will be converted to the current DTD version. If the newFile parameter is provided, the converted schema will be written to the specified file.

string ConvertSchemaFile (string $filename, [string $newVersion = NULL], [string $newFile = NULL])
  • string $filename: Name of XML schema file that will be converted.
  • string $newVersion: DTD version to convert to.
  • string $newFile: File name of (converted) output file.
ConvertSchemaString (line 1679)

Converts an XML schema string to the specified DTD version.

Call this method to convert a string containing an XML schema to a different AXMLS DTD version. For instance, to convert a schema created for an pre-1.0 version for AXMLS (DTD version 0.1) to a newer version of the DTD (e.g. 0.2). If no DTD version parameter is specified, the schema will be converted to the current DTD version. If the newFile parameter is provided, the converted schema will be written to the specified file.

string ConvertSchemaString (string $schema, [string $newVersion = NULL], [string $newFile = NULL])
  • string $schema: String containing XML schema that will be converted.
  • string $newVersion: DTD version to convert to.
  • string $newFile: File name of (converted) output file.
Destroy (line 2166)

Destroys an adoSchema object.

Call this method to clean up after an adoSchema object that is no longer in use.

  • deprecated: adoSchema now cleans up automatically.
void Destroy ()
ExecuteInline (line 1360)

Enables/disables inline SQL execution.

Call this method to enable or disable inline execution of the schema. If the mode is set to TRUE (inline execution), AXMLS applies the SQL to the database immediately as each schema entity is parsed. If the mode is set to FALSE (post execution), AXMLS parses the entire schema and you will need to call adoSchema::ExecuteSchema() to apply the schema to the database.

bool ExecuteInline ([bool $mode = NULL])
  • bool $mode: execute
ExecuteSchema (line 1546)

Applies the current XML schema to the database (post execution).

Call this method to apply the current schema (generally created by calling ParseSchema() or ParseSchemaString() ) to the database (creating the tables, indexes, and executing other SQL specified in the schema) after parsing.

integer ExecuteSchema ([array $sqlArray = NULL], [boolean $continueOnErr = NULL])
  • array $sqlArray: Array of SQL statements that will be applied rather than the current schema.
  • boolean $continueOnErr: Continue to apply the schema even if an error occurs.
ExtractSchema (line 1909)

Extracts an XML schema from an existing database.

Call this method to create an XML schema string from an existing database. If the data parameter is set to TRUE, AXMLS will include the data from the database in the schema.

  • return: Generated XML schema
string ExtractSchema ([boolean $data = FALSE])
  • boolean $data: Include data in schema dump
ParseSchema (line 1400)

Loads an XML schema from a file and converts it to SQL.

Call this method to load the specified schema (see the DTD for the proper format) from the filesystem and generate the SQL necessary to create the database described.

array ParseSchema (mixed $filename, [bool $returnSchema = FALSE], string $file)
  • string $file: Name of XML schema file.
  • bool $returnSchema: Return schema rather than parsing.
ParseSchemaFile (line 1417)

Loads an XML schema from a file and converts it to SQL.

Call this method to load the specified schema from a file (see the DTD for the proper format) and generate the SQL necessary to create the database described by the schema.

array ParseSchemaFile (mixed $filename, [bool $returnSchema = FALSE], string $file)
  • string $file: Name of XML schema file.
  • bool $returnSchema: Return schema rather than parsing.
ParseSchemaString (line 1465)

Converts an XML schema string to SQL.

Call this method to parse a string containing an XML schema (see the DTD for the proper format) and generate the SQL necessary to create the database described by the schema.

array ParseSchemaString (string $xmlstring, [bool $returnSchema = FALSE])
  • string $xmlstring: XML schema string.
  • bool $returnSchema: Return schema rather than parsing.
PrintSQL (line 1573)

Returns the current SQL array.

Call this method to fetch the array of SQL queries resulting from ParseSchema() or ParseSchemaString().

  • return: Array of SQL statements or FALSE if an error occurs
array PrintSQL ([string $format = 'NONE'])
  • string $format: Format: HTML, TEXT, or NONE (PHP array)
RemoveSchema (line 1508)

Loads an XML schema from a file and converts it to uninstallation SQL.

Call this method to load the specified schema (see the DTD for the proper format) from the filesystem and generate the SQL necessary to remove the database described.

array RemoveSchema (mixed $filename, [bool $returnSchema = FALSE], string $file)
  • string $file: Name of XML schema file.
  • bool $returnSchema: Return schema rather than parsing.
RemoveSchemaString (line 1523)

Converts an XML schema string to uninstallation SQL.

Call this method to parse a string containing an XML schema (see the DTD for the proper format) and generate the SQL necessary to uninstall the database described by the schema.

array RemoveSchemaString (string $schema, [bool $returnSchema = FALSE])
  • string $schema: XML schema string.
  • bool $returnSchema: Return schema rather than parsing.
SaveSQL (line 1586)

Saves the current SQL array to the local filesystem as a list of SQL queries.

Call this method to save the array of SQL queries (generally resulting from a parsed XML schema) to the filesystem.

  • return: TRUE if save is successful, else FALSE.
boolean SaveSQL ([string $filename = './schema.sql'])
  • string $filename: Path and name where the file should be saved.
SchemaFileVersion (line 1861)

Returns the AXMLS Schema Version of the requested XML schema file.

Call this method to obtain the AXMLS DTD version of the requested XML schema file.

string SchemaFileVersion (string $filename)
  • string $filename: AXMLS schema file
SchemaStringVersion (line 1887)

Returns the AXMLS Schema Version of the provided XML schema string.

Call this method to obtain the AXMLS DTD version of the provided XML schema string.

string SchemaStringVersion (string $xmlstring)
  • string $xmlstring: XML schema string
SetPrefix (line 2016)

Sets a prefix for database objects

Call this method to set a standard prefix that will be prepended to all database tables and indices when the schema is parsed. Calling setPrefix with no arguments clears the prefix.

  • return: TRUE if successful, else FALSE
boolean SetPrefix ([string $prefix = ''], [boolean $underscore = TRUE])
  • string $prefix: Prefix that will be prepended.
  • boolean $underscore: If TRUE, automatically append an underscore character to the prefix.
SetUpgradeMethod (line 1318)

Sets the method to be used for upgrading an existing database

Use this method to specify how existing database objects should be upgraded. The method option can be set to ALTER, REPLACE, BEST, or NONE. ALTER attempts to alter each database object directly, REPLACE attempts to rebuild each object from scratch, BEST attempts to determine the best upgrade method for each object, and NONE disables upgrading.

This method is not yet used by AXMLS, but exists for backward compatibility. The ALTER method is automatically assumed when the adoSchema object is instantiated; other upgrade methods are not currently supported.

  • return: Upgrade method used
string SetUpgradeMethod ([string $method = ''])
  • string $method: Upgrade method (ALTER|REPLACE|BEST|NONE)
TransformSchema (line 1750)
void TransformSchema (mixed $schema, mixed $xsl, [mixed $schematype = 'string'])

Documentation generated on Tue, 27 Jul 2004 20:05:45 -0400 by phpDocumentor 1.3.0RC3