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.
파일 보기 프로젝트 열기: pkp/pkp-lib 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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