PHP Класс adoSchema, pkp-lib

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.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$continueOnError Continue SQL execution if errors occur
$currentElement Current XML element
$db ADOdb connection object
$debug System debug
$dict ADOdb Data Dictionary
$executeInline Execute SQL inline as it is generated
$mgq Original Magic Quotes Runtime value
$objectPrefix Optional object prefix
$schemaVersion Current schema version
$sqlArray Array containing SQL queries to generate all objects
$success Success of last Schema execution
$upgrade If set (to 'ALTER' or 'REPLACE'), upgrade an existing database
$versionRegex Regular expression to find schema version

Открытые методы

Метод Описание
ContinueOnError ( boolean $mode = NULL ) : boolean Enables/disables SQL continue on error.
ConvertSchemaFile ( string $filename, string $newVersion = NULL, string $newFile = NULL ) : string Converts an XML schema file to the specified DTD version.
ConvertSchemaString ( string $schema, string $newVersion = NULL, string $newFile = NULL ) : string Converts an XML schema string to the specified DTD version.
Destroy ( ) Destroys an adoSchema object.
ExecuteInline ( boolean $mode = NULL ) : boolean Enables/disables inline SQL execution.
ExecuteSchema ( array $sqlArray = NULL, boolean $continueOnErr = NULL ) Applies the current XML schema to the database (post execution).
ExtractSchema ( boolean $data = FALSE ) : string Extracts an XML schema from an existing database.
ParseSchema ( $filename, boolean $returnSchema = FALSE ) : array Loads an XML schema from a file and converts it to SQL.
ParseSchemaFile ( $filename, boolean $returnSchema = FALSE ) : array Loads an XML schema from a file and converts it to SQL.
ParseSchemaString ( string $xmlstring, boolean $returnSchema = FALSE ) : array Converts an XML schema string to SQL.
PrintSQL ( string $format = 'NONE' ) : array Returns the current SQL array.
RemoveSchema ( $filename, boolean $returnSchema = FALSE ) : array Loads an XML schema from a file and converts it to uninstallation SQL.
RemoveSchemaString ( string $schema, boolean $returnSchema = FALSE ) : array Converts an XML schema string to uninstallation SQL.
SaveSQL ( string $filename = './schema.sql' ) : boolean Saves the current SQL array to the local filesystem as a list of SQL queries.
SchemaFileVersion ( string $filename ) : string Returns the AXMLS Schema Version of the requested XML schema file.
SchemaStringVersion ( string $xmlstring ) : string Returns the AXMLS Schema Version of the provided XML schema string.
SetPrefix ( string $prefix = '', boolean $underscore = TRUE ) : boolean Sets a prefix for database objects
SetUpgradeMethod ( string $method = '' ) Sets the method to be used for upgrading an existing database
TransformSchema ( $schema, $xsl, $schematype = 'string' )
_file_get_contents ( $path ) compat for pre-4.3 - jlim
_tag_cdata ( &$parser, $cdata ) XML Callback to process CDATA elements
_tag_close ( &$parser, $tag ) XML Callback to process end elements
_tag_open ( &$parser, $tag, $attributes ) XML Callback to process start elements
addSQL ( mixed $sql = NULL ) : boolean Adds SQL into the SQL array.
adoSchema ( object $db ) Creates an adoSchema object
clearSQL ( ) Clears the array of generated SQL.
create_parser ( ) : object Create an xml parser
getSQL ( string $format = NULL, $sqlArray = NULL ) : mixed Gets the SQL array in the specified format.
prefix ( string $name = '' ) : string Returns an object name with the current prefix prepended.
supportedPlatform ( string $platform = NULL ) Checks if element references a specific platform
xslt_error_handler ( object $parser, integer $errno, integer $level, array $fields ) Processes XSLT transformation errors

Описание методов

ContinueOnError() публичный Метод

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.
public ContinueOnError ( boolean $mode = NULL ) : boolean
$mode boolean execute
Результат boolean current continueOnError mode

ConvertSchemaFile() публичный Метод

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.
См. также: ConvertSchemaString()
public ConvertSchemaFile ( string $filename, string $newVersion = NULL, string $newFile = NULL ) : string
$filename string Name of XML schema file that will be converted.
$newVersion string DTD version to convert to.
$newFile string File name of (converted) output file.
Результат string Converted XML schema or FALSE if an error occurs.

ConvertSchemaString() публичный Метод

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.
См. также: ConvertSchemaFile()
public ConvertSchemaString ( string $schema, string $newVersion = NULL, string $newFile = NULL ) : string
$schema string String containing XML schema that will be converted.
$newVersion string DTD version to convert to.
$newFile string File name of (converted) output file.
Результат string Converted XML schema or FALSE if an error occurs.

Destroy() публичный Метод

Call this method to clean up after an adoSchema object that is no longer in use.
Устаревший: adoSchema now cleans up automatically.
public Destroy ( )

ExecuteInline() публичный Метод

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.
public ExecuteInline ( boolean $mode = NULL ) : boolean
$mode boolean execute
Результат boolean current execution mode

ExecuteSchema() публичный Метод

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.
public ExecuteSchema ( array $sqlArray = NULL, boolean $continueOnErr = NULL )
$sqlArray array Array of SQL statements that will be applied rather than the current schema.
$continueOnErr boolean Continue to apply the schema even if an error occurs.

ExtractSchema() публичный Метод

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.
public ExtractSchema ( boolean $data = FALSE ) : string
$data boolean Include data in schema dump
Результат string Generated XML schema

ParseSchema() публичный Метод

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.
См. также: ParseSchemaString()
public ParseSchema ( $filename, boolean $returnSchema = FALSE ) : array
$returnSchema boolean Return schema rather than parsing.
Результат array Array of SQL queries, ready to execute

ParseSchemaFile() публичный Метод

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.
Устаревший: Replaced by adoSchema::ParseSchema() and adoSchema::ParseSchemaString()
public ParseSchemaFile ( $filename, boolean $returnSchema = FALSE ) : array
$returnSchema boolean Return schema rather than parsing.
Результат array Array of SQL queries, ready to execute.

ParseSchemaString() публичный Метод

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.
См. также: ParseSchema()
public ParseSchemaString ( string $xmlstring, boolean $returnSchema = FALSE ) : array
$xmlstring string XML schema string.
$returnSchema boolean Return schema rather than parsing.
Результат array Array of SQL queries, ready to execute.

PrintSQL() публичный Метод

Call this method to fetch the array of SQL queries resulting from ParseSchema() or ParseSchemaString().
public PrintSQL ( string $format = 'NONE' ) : array
$format string Format: HTML, TEXT, or NONE (PHP array)
Результат array Array of SQL statements or FALSE if an error occurs

RemoveSchema() публичный Метод

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.
См. также: RemoveSchemaString()
public RemoveSchema ( $filename, boolean $returnSchema = FALSE ) : array
$returnSchema boolean Return schema rather than parsing.
Результат array Array of SQL queries, ready to execute

RemoveSchemaString() публичный Метод

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.
См. также: RemoveSchema()
public RemoveSchemaString ( string $schema, boolean $returnSchema = FALSE ) : array
$schema string XML schema string.
$returnSchema boolean Return schema rather than parsing.
Результат array Array of SQL queries, ready to execute.

SaveSQL() публичный Метод

Call this method to save the array of SQL queries (generally resulting from a parsed XML schema) to the filesystem.
public SaveSQL ( string $filename = './schema.sql' ) : boolean
$filename string Path and name where the file should be saved.
Результат boolean TRUE if save is successful, else FALSE.

SchemaFileVersion() публичный Метод

Call this method to obtain the AXMLS DTD version of the requested XML schema file.
См. также: SchemaStringVersion()
public SchemaFileVersion ( string $filename ) : string
$filename string AXMLS schema file
Результат string Schema version number or FALSE on error

SchemaStringVersion() публичный Метод

Call this method to obtain the AXMLS DTD version of the provided XML schema string.
См. также: SchemaFileVersion()
public SchemaStringVersion ( string $xmlstring ) : string
$xmlstring string XML schema string
Результат string Schema version number or FALSE on error

SetPrefix() публичный Метод

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.
public SetPrefix ( string $prefix = '', boolean $underscore = TRUE ) : boolean
$prefix string Prefix that will be prepended.
$underscore boolean If TRUE, automatically append an underscore character to the prefix.
Результат boolean TRUE if successful, else FALSE

SetUpgradeMethod() публичный Метод

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.
public SetUpgradeMethod ( string $method = '' )
$method string Upgrade method (ALTER|REPLACE|BEST|NONE)

TransformSchema() публичный Метод

public TransformSchema ( $schema, $xsl, $schematype = 'string' )

_file_get_contents() публичный Метод

compat for pre-4.3 - jlim
public _file_get_contents ( $path )

_tag_cdata() публичный Метод

XML Callback to process CDATA elements
public _tag_cdata ( &$parser, $cdata )

_tag_close() публичный Метод

XML Callback to process end elements
public _tag_close ( &$parser, $tag )

_tag_open() публичный Метод

XML Callback to process start elements
public _tag_open ( &$parser, $tag, $attributes )

addSQL() публичный Метод

Adds SQL into the SQL array.
public addSQL ( mixed $sql = NULL ) : boolean
$sql mixed SQL to Add
Результат boolean TRUE if successful, else FALSE.

adoSchema() публичный Метод

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.
public adoSchema ( object $db )
$db object ADOdb database connection object.

clearSQL() публичный Метод

Clears the array of generated SQL.
public clearSQL ( )

create_parser() публичный Метод

Create an xml parser
public create_parser ( ) : object
Результат object PHP XML parser object

getSQL() публичный Метод

Gets the SQL array in the specified format.
public getSQL ( string $format = NULL, $sqlArray = NULL ) : mixed
$format string Format
Результат mixed SQL

prefix() публичный Метод

Returns an object name with the current prefix prepended.
public prefix ( string $name = '' ) : string
$name string Name
Результат string Prefixed name

supportedPlatform() публичный Метод

Checks if element references a specific platform
public supportedPlatform ( string $platform = NULL )
$platform string Requested platform

xslt_error_handler() публичный Метод

Processes XSLT transformation errors
public xslt_error_handler ( object $parser, integer $errno, integer $level, array $fields )
$parser object XML parser object
$errno integer Error number
$level integer Error level
$fields array Error information fields

Описание свойств

$continueOnError публичное свойство

Continue SQL execution if errors occur
public $continueOnError

$currentElement публичное свойство

Current XML element
public $currentElement

$db публичное свойство

ADOdb connection object
public $db

$debug публичное свойство

System debug
public $debug

$dict публичное свойство

ADOdb Data Dictionary
public $dict

$executeInline публичное свойство

Execute SQL inline as it is generated
public $executeInline

$mgq публичное свойство

Original Magic Quotes Runtime value
public $mgq

$objectPrefix публичное свойство

Optional object prefix
public $objectPrefix

$schemaVersion публичное свойство

Current schema version
public $schemaVersion

$sqlArray публичное свойство

Array containing SQL queries to generate all objects
public $sqlArray

$success публичное свойство

Success of last Schema execution
public $success

$upgrade публичное свойство

If set (to 'ALTER' or 'REPLACE'), upgrade an existing database
public $upgrade

$versionRegex публичное свойство

Regular expression to find schema version
public $versionRegex