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

Class: adoSchema

Source Location: /includes/classes/adodb/adodb-xmlschema.inc.php

Class Overview


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


Author(s):

  • Richard Tango-Lowy & Dan Cech

Version:

  • $Revision: 19377 $

Variables

Methods



Class Details

[line 1216]
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.




Tags:

tutorial:  getting_started.pkg
author:  Richard Tango-Lowy & Dan Cech
version:  $Revision: 19377 $


[ Top ]


Class Variables

$continueOnError =

[line 1291]



Tags:

var:  Continue SQL execution if errors occur

Type:   bool


[ Top ]

$executeInline =

[line 1286]



Tags:

var:  Execute SQL inline as it is generated

Type:   bool


[ Top ]

$success =

[line 1281]



Tags:

var:  Success of last Schema execution

Type:   int


[ Top ]



Class Methods


constructor adoSchema [line 1302]

adoSchema adoSchema( &$db, object $db)

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.




Parameters:

object   $db   ADOdb database connection object.
   &$db  

[ Top ]

method ContinueOnError [line 1396]

bool ContinueOnError( [bool $mode = NULL])

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.




Tags:

return:  current continueOnError mode
see:  addSQL(), adoSchema::ExecuteSchema()


Parameters:

bool   $mode   execute

[ Top ]

method ConvertSchemaFile [line 1747]

string ConvertSchemaFile( string $filename, [string $newVersion = NULL], [string $newFile = NULL])

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.




Tags:

return:  Converted XML schema or FALSE if an error occurs.
see:  adoSchema::ConvertSchemaString()


Parameters:

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.

[ Top ]

method ConvertSchemaString [line 1699]

string ConvertSchemaString( string $schema, [string $newVersion = NULL], [string $newFile = NULL])

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.




Tags:

return:  Converted XML schema or FALSE if an error occurs.
see:  adoSchema::ConvertSchemaFile()


Parameters:

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.

[ Top ]

method Destroy [line 2193]

void Destroy( )

Destroys an adoSchema object.

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




Tags:

deprecated:  adoSchema now cleans up automatically.


[ Top ]

method ExecuteInline [line 1375]

bool ExecuteInline( [bool $mode = NULL])

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.




Tags:

return:  current execution mode
see:  adoSchema::ParseSchema(), adoSchema::ExecuteSchema()


Parameters:

bool   $mode   execute

[ Top ]

method ExecuteSchema [line 1565]

integer ExecuteSchema( [array $sqlArray = NULL], [boolean $continueOnErr = NULL])

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.




Tags:

return:  0 if failure, 1 if errors, 2 if successful.
see:  adoSchema::ParseSchema(), adoSchema::ParseSchemaString(), adoSchema::ExecuteInline()


Parameters:

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.

[ Top ]

method ExtractSchema [line 1936]

string ExtractSchema( [boolean $data = FALSE])

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.




Tags:

return:  Generated XML schema


Parameters:

boolean   $data   Include data in schema dump

[ Top ]

method ParseSchema [line 1415]

array ParseSchema( $filename, [bool $returnSchema = FALSE], string $file)

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.




Tags:

return:  Array of SQL queries, ready to execute
see:  adoSchema::ParseSchemaString()


Parameters:

string   $file   Name of XML schema file.
bool   $returnSchema   Return schema rather than parsing.
   $filename  

[ Top ]

method ParseSchemaFile [line 1432]

array ParseSchemaFile( $filename, [bool $returnSchema = FALSE], string $file)

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.




Tags:

return:  Array of SQL queries, ready to execute.
see:  adoSchema::ParseSchema(), adoSchema::ParseSchemaString()
deprecated:  Replaced by adoSchema::ParseSchema() and adoSchema::ParseSchemaString()


Parameters:

string   $file   Name of XML schema file.
bool   $returnSchema   Return schema rather than parsing.
   $filename  

[ Top ]

method ParseSchemaString [line 1484]

array ParseSchemaString( string $xmlstring, [bool $returnSchema = FALSE])

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.




Tags:

return:  Array of SQL queries, ready to execute.
see:  adoSchema::ParseSchema()


Parameters:

string   $xmlstring   XML schema string.
bool   $returnSchema   Return schema rather than parsing.

[ Top ]

method PrintSQL [line 1592]

array PrintSQL( [string $format = 'NONE'])

Returns the current SQL array.

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




Tags:

return:  Array of SQL statements or FALSE if an error occurs


Parameters:

string   $format   Format: HTML, TEXT, or NONE (PHP array)

[ Top ]

method RemoveSchema [line 1527]

array RemoveSchema( $filename, [bool $returnSchema = FALSE], string $file)

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.




Tags:

return:  Array of SQL queries, ready to execute
see:  adoSchema::RemoveSchemaString()


Parameters:

string   $file   Name of XML schema file.
bool   $returnSchema   Return schema rather than parsing.
   $filename  

[ Top ]

method RemoveSchemaString [line 1542]

array RemoveSchemaString( string $schema, [bool $returnSchema = FALSE])

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.




Tags:

return:  Array of SQL queries, ready to execute.
see:  adoSchema::RemoveSchema()


Parameters:

string   $schema   XML schema string.
bool   $returnSchema   Return schema rather than parsing.

[ Top ]

method SaveSQL [line 1606]

boolean SaveSQL( [string $filename = './schema.sql'])

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.




Tags:

return:  TRUE if save is successful, else FALSE.


Parameters:

string   $filename   Path and name where the file should be saved.

[ Top ]

method SchemaFileVersion [line 1888]

string SchemaFileVersion( string $filename)

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.




Tags:

return:  Schema version number or FALSE on error
see:  adoSchema::SchemaStringVersion()


Parameters:

string   $filename   AXMLS schema file

[ Top ]

method SchemaStringVersion [line 1914]

string SchemaStringVersion( string $xmlstring)

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.




Tags:

return:  Schema version number or FALSE on error
see:  adoSchema::SchemaFileVersion()


Parameters:

string   $xmlstring   XML schema string

[ Top ]

method SetPrefix [line 2043]

boolean SetPrefix( [string $prefix = ''], [boolean $underscore = TRUE])

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.




Tags:

return:  TRUE if successful, else FALSE


Parameters:

string   $prefix   Prefix that will be prepended.
boolean   $underscore   If TRUE, automatically append an underscore character to the prefix.

[ Top ]

method SetUpgradeMethod [line 1333]

string SetUpgradeMethod( [string $method = ''])

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.




Tags:

return:  Upgrade method used


Parameters:

string   $method   Upgrade method (ALTER|REPLACE|BEST|NONE)

[ Top ]

method TransformSchema [line 1777]

void TransformSchema( $schema, $xsl, [ $schematype = 'string'])



Parameters:

   $schema  
   $xsl  
   $schematype  

[ Top ]

method _file_get_contents [line 1725]

void _file_get_contents( $path)



Parameters:

   $path  

[ Top ]


Documentation generated on Fri, 18 Jul 2008 21:42:36 +0200 by phpDocumentor 1.4.1