【php开源代码栏目提醒】:网学会员为广大网友收集整理了,adodb-xmlschema03.inc.php,希望对大家有所帮助!
<?php
// Copyright (c) 2004-2005 ars Cognita Inc., all rights reserved
/* ******************************************************************************
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
*******************************************************************************/
/**
* xmlschema is a class that allows the user to quickly and easily
* build a database on any ADOdb-supported platform using a simple
* XML schema.
*
* Last Editor: $Author: jlim $
* @author Richard Tango-Lowy & Dan Cech
* @version $Revision: 1.62 $
*
* @package axmls
* @tutorial getting_started.pkg
*/
function _file_get_contents($file)
{
if (function_exists('file_get_contents')) return file_get_contents($file);
$f = fopen($file,'r');
if (!$f) return '';
$t = '';
while ($s = fread($f,100000)) $t .= $s;
fclose($f);
return $t;
}
/**
* Debug on or off
*/
if( !defined( 'XMLS_DEBUG' ) ) {
define( 'XMLS_DEBUG', FALSE );
}
/**
* Default prefix key
*/
if( !defined( 'XMLS_PREFIX' ) ) {
define( 'XMLS_PREFIX', '%%P' );
}
/**
* Maximum length allowed for object prefix
*/
if( !defined( 'XMLS_PREFIX_MAXLEN' ) ) {
define( 'XMLS_PREFIX_MAXLEN', 10 );
}
/**
* Execute SQL inline as it is generated
*/
if( !defined( 'XMLS_EXECUTE_INLINE' ) ) {
define( 'XMLS_EXECUTE_INLINE', FALSE );
}
/**
* Continue SQL Execution if an error occurs?
*/
if( !defined( 'XMLS_CONTINUE_ON_ERROR' ) ) {
define( 'XMLS_CONTINUE_ON_ERROR', FALSE );
}
/**
* Current Schema Version
*/
if( !defined( 'XMLS_SCHEMA_VERSION' ) ) {
define( 'XMLS_SCHEMA_VERSION', '0.3' );
}
/**
* Default Schema Version. Used for Schemas without an explicit version set.
*/
if( !defined( 'XMLS_DEFAULT_SCHEMA_VERSION' ) ) {
define( 'XMLS_DEFAULT_SCHEMA_VERSION', '0.1' );
}
/**
* How to handle data rows that already exist in a database during and upgrade.
* Options are INSERT (attempts to insert duplicate rows), UPDATE (updates existing
* rows) and IGNORE (ignores existing rows).
*/
if( !defined( 'XMLS_MODE_INSERT' ) ) {
define( 'XMLS_MODE_INSERT', 0 );
}
if( !defined( 'XMLS_MODE_UPDATE' ) ) {
define( 'XMLS_MODE_UPDATE', 1 );
}
if( !defined( 'XMLS_MODE_IGNORE' ) ) {
define( 'XMLS_MODE_IGNORE', 2 );
}
if( !defined( 'XMLS_EXISTING_DATA' ) ) {
define( 'XMLS_EXISTING_DATA', XMLS_MODE_INSERT );
}
/**
* Default Schema Version. Used for Schemas without an explicit version set.
*/
if( !defined( 'XMLS_DEFAULT_UPGRADE_METHOD' ) ) {
define( 'XMLS_DEFAULT_UPGRADE_METHOD', 'ALTER' );
}
/**
* Include the main ADODB library
*/
if( !defined( '_ADODB_LAYER' ) ) {
require( 'adodb.inc.php' );
require( 'adodb-datadict.inc.php' );
}
/**
* Abstract DB Object. This class provides basic methods for database objects, such
* as tables and indexes.
*
* @package a
xmls
* @access private
*/
class dbObject {
/**
* var object Parent
*/
var $parent;
/**
* var string current element
*/
var $currentElement;
/**
* NOP
*/
function dbObject( &$parent, $attributes = NULL ) {
$this->parent = $parent;
}
/**
* XML Callback to process start elements
*
* @access private
*/
function _tag_open( &$parser, $tag, $attributes ) {
}
/**
* XML Callback to process CDATA elements
*
* @access private
*/
function _tag_cdata( &$parser, $cdata ) {
}
/**
* XML Callback to process end elements
*
* @access private
*/
function _tag_close( &$parser, $tag ) {
}
function create() {
return array();
}
/**
* Destroys the object
*/
function destroy() {
unset( $this );
}
/**
* Checks whether the specified RDBMS is supported by the current
* database object or its ranking ancestor.
*
* @param string $platform RDBMS platform name (from ADODB platform list).
* @return boolean TRUE if RDBMS is supported; otherwise returns FALSE.
*/
function supportedPlatform( $platform = NULL ) {
return is_object( $this->parent ) ? $this->parent->supportedPlatform( $platform ) : TRUE;
}
/**
* Returns the prefix set by the ranking ancestor of the database object.
*
* @param string $name Prefix string.
* @return string Prefix.
*/
function prefix( $name = '' ) {
return is_object( $this->parent ) ? $this->parent->prefix( $name ) : $name;
}
/**
* Extracts a field ID from the specified field.
*
* @param string $field Field.
* @return string Field ID.
*/
function FieldID( $field ) {
return strtoupper( preg_replace( '/^`(.+)`$/', '$1