package.xml 100644 765 765 116225 11150346546 6443
MDB2_Schemapear.php.netMDB2XML based database schema managerPEAR::MDB2_Schema enables users to maintain RDBMS independant schema
files in XML that can be used to create, alter and drop database entities
and insert data into a database. Reverse engineering database schemas from
existing databases is also supported. The format is compatible with both
PEAR::MDB and Metabase.Lukas Kahwe Smithlsmithsmith@pooteeweet.orgnoIgor Feghaliifeghaliifeghali@php.netyesHelgi Thormardufuzdufuz@php.netno2009-02-220.8.50.8.0betabetaBSD License- PEAR dependency updated (Bug #15923)
- XML_DTD dependency updated (past releases of XML_DTD doesn't works anymore. release 0.5.1 works only with PHP 5).
- Fixed 'disable_queries' and 'show_structure' options that were malfunctioning in mdb2_schematool web version
- Added an option to not drop obsolete tables when updating (Request #15278). It defaults not to drop, which reverts the behavior introduced in Release 0.8.3
open todo items:
- Clean up output of getDefinitionFromDatabase(). Sync it with Parser and Parser2.
- Automatically load reserved keywords
- Make MDB2_Schema loadable via MDB2_Driver_Common::loadModule() (Bug #8270)
- Allow simple if statements that mean that anything enclosed is only executed
if it meets certain criterias based on that version number (or some other
variable). This would enable people to add DML statements that are only
executed when updating from a specific version.
- Modularize Writer code or remake it
- Add specific error codes for Validate class
- Add support for ORDER clauses on UPDATEs (to resolve the duplicate key
problem)
- Update description.schema.xml
- Create unit test for comparedefinitions()
- Create unit test for initializetable()
- Create unit test to compare the expected array definition with what is parsed
- Improve validateDataFieldValue() to validate <column>
- Provide more info on MDB2_Schema_Validate errors (output parsed value and expected value)
- Views support
- Fulltext index support
- PKs as constraints, not indices
- Creation of constraints only after all tables have been created/updated to avoid invalid references.4.3.21.7.0MDB2pear.php.net2.5.0b1XML_Parserpear.php.net1.2.8XML_DTDpear.php.net0.5.1XML_Serializerpear.php.net0.18.00.8.50.8.0betabeta2009-02-22BSD License- PEAR dependency updated (Bug #15923)
- XML_DTD dependency updated (past releases of XML_DTD doesn't works anymore. release 0.5.1 works only with PHP 5).
- Fixed 'disable_queries' and 'show_structure' options that were malfunctioning in mdb2_schematool web version
- Added an option to not drop obsolete tables when updating (Request #15278). It defaults not to drop, which reverts the behavior introduced in Release 0.8.3
open todo items:
- Clean up output of getDefinitionFromDatabase(). Sync it with Parser and Parser2.
- Automatically load reserved keywords
- Make MDB2_Schema loadable via MDB2_Driver_Common::loadModule() (Bug #8270)
- Allow simple if statements that mean that anything enclosed is only executed
if it meets certain criterias based on that version number (or some other
variable). This would enable people to add DML statements that are only
executed when updating from a specific version.
- Modularize Writer code or remake it
- Add specific error codes for Validate class
- Add support for ORDER clauses on UPDATEs (to resolve the duplicate key
problem)
- Update description.schema.xml
- Create unit test for comparedefinitions()
- Create unit test for initializetable()
- Create unit test to compare the expected array definition with what is parsed
- Improve validateDataFieldValue() to validate <column>
- Provide more info on MDB2_Schema_Validate errors (output parsed value and expected value)
- Views support
- Fulltext index support
- PKs as constraints, not indices
- Creation of constraints only after all tables have been created/updated to avoid invalid references.0.8.40.8.0betabeta2008-11-17BSD License- fixed warning in validateTable() that was introduced in last release (Bug #15055)
- fixed interpreter for mdb2_schematool, plus it is now been installed to bin_dir (now, really!)
- mdb2_schematool has a new feature: initialize database
- mdb2_schematool can now be used to dump data and/or database structure
open todo items:
- Clean up output of getDefinitionFromDatabase(). Sync it with Parser and Parser2.
- Automatically load reserved keywords
- Make MDB2_Schema loadable via MDB2_Driver_Common::loadModule() (Bug #8270)
- Allow simple if statements that mean that anything enclosed is only executed
if it meets certain criterias based on that version number (or some other
variable). This would enable people to add DML statements that are only
executed when updating from a specific version.
- Modularize Writer code or remake it
- Add specific error codes for Validate class
- Add support for ORDER clauses on UPDATEs (to resolve the duplicate key
problem)
- Update description.schema.xml
- Create unit test for comparedefinitions()
- Create unit test for initializetable()
- Create unit test to compare the expected array definition with what is parsed
- Improve validateDataFieldValue() to validate <column>
- Provide more info on MDB2_Schema_Validate errors (output parsed value and expected value)
- Views support
- Fulltext index support0.8.30.8.0betabeta2008-11-16BSD License- updateDatabase() cannot add UNIQUE attribute to an existing index (Bug #13977). Patch by Holger Schletz
- updateDatabase() keeps old default value even though new column has no default (Bug #13836). Patch by Holger Schletz
- Obsolete tables and sequences not dropped on updateDatabase() (Bug #13608). Patch by Holger Schletz
- Error when creating a new index for a renamed table (Bug #13397)
- Makes use of MDB2::databaseExists() to check whether updating database exists (Bug #13073). This feature was removed on previous release and now is back again.
- createDatabase() correctly lower/upper database name when portability option deems so.
- mdb2_schematool now disables transactions
- mdb2_schematool was missing argument "help"
- mdb2_schematool moved from "bin" to "scripts" folder. now installs to pear_bin dir
- Schema validation not failing when autoincrement field is defined but another column is used as primary key (Bug #14213)
- Accepting NOW() as value for timestamp fields on schema validation (Bug #14052). Patch by Holger Schletz
- Introducing www/mdb2_schematool that is a rewrite of docs/examples/example.php and is now installed to web root
- Web frontend (www/mdb2_schematool) has new options "DBA_username" and "DBA_password"
- Tests missing sequences on database dump (Bug #13562). Patch by Luca Corbo
- When reverse engineering a database, the XML schema file will have <charset> forced to UTF8
open todo items:
- Clean up output of getDefinitionFromDatabase(). Sync it with Parser and Parser2.
- Automatically load reserved keywords
- Make MDB2_Schema loadable via MDB2_Driver_Common::loadModule() (Bug #8270)
- Allow simple if statements that mean that anything enclosed is only executed
if it meets certain criterias based on that version number (or some other
variable). This would enable people to add DML statements that are only
executed when updating from a specific version.
- Modularize Writer code or remake it
- Add specific error codes for Validate class
- Add support for ORDER clauses on UPDATEs (to resolve the duplicate key
problem)
- Update description.schema.xml
- Create unit test for comparedefinitions()
- Create unit test for initializetable()
- Create unit test to compare the expected array definition with what is parsed
- Improve validateDataFieldValue() to validate <column>
- Provide more info on MDB2_Schema_Validate errors (output parsed value and expected value)
- Views support
- Fulltext index support0.8.20.8.0betabeta2008-02-23BSD License- updated dependency
- updated license disclaimer in source code files
- use quoteIdentifier in getInstructionFields() (Bug #13037)
- After database creation, sqlite db connection not usable (Bug #11920)
- Supporting Database Charset (Bug #12908)
- writeInitialization() fails at given conditions (Bug #12950)
- drop usage of listDatabases() (Bug #12636), as a consequence updateDatabase() doesn't check anymore whether updating database exists
- index-length documented and included in Parser2 (Bug #12540)
- xsl transformation chooses wrong value for length (Bug #12261)
- added README file for docs dir
- the correct variable name for warning is "warnings" not "operation" in example script
- disabled transactions in the example script
- introducing mdb2_schematool, a command line tool to dump and load schemas
open todo items:
- Clean up output of getDefinitionFromDatabase(). Sync it with Parser and Parser2.
- Automatically load reserved keywords
- Make MDB2_Schema loadable via MDB2_Driver_Common::loadModule() (Bug #8270)
- Allow simple if statements that mean that anything enclosed is only executed
if it meets certain criterias based on that version number (or some other
variable). This would enable people to add DML statements that are only
executed when updating from a specific version.
- Modularize Writer code or remake it
- Add specific error codes for Validate class
- Add support for ORDER clauses on UPDATEs (to resolve the duplicate key
problem)
- Update description.schema.xml
- Create unit test for comparedefinitions()
- Create unit test for initializetable()
- Create unit test to compare the expected array definition with what is parsed
- Improve validateDataFieldValue() to validate <column>
- Provide more info on MDB2_Schema_Validate errors (output parsed value and expected value)
- Views support
- Fulltext index support0.8.10.8.0betabeta2007-08-30BSD License- updated dependency
open todo items:
- Clean up output of getDefinitionFromDatabase(). Sync it with Parser and Parser2.
- Automatically load reserved keywords
- Make MDB2_Schema loadable via MDB2_Driver_Common::loadModule() (Bug #8270)
- Allow simple if statements that mean that anything enclosed is only executed
if it meets certain criterias based on that version number (or some other
variable). This would enable people to add DML statements that are only
executed when updating from a specific version.
- Modularize Writer code or remake it
- Add specific error codes for Validate class
- Add support for ORDER clauses on UPDATEs (to resolve the duplicate key
problem)
- Update description.schema.xml
- Create unit test for comparedefinitions()
- Create unit test for initializetable()
- Create unit test to compare the expected array definition with what is parsed
- Improve validateDataFieldValue() to validate <column>
- Provide more info on MDB2_Schema_Validate errors (output parsed value and expected value)
- Views support
- Fulltext index support0.8.00.8.0betabeta2007-08-20BSD License- Primary Key is removed when updating a table against its XML (Bug #11604)
- Added support to INSERT...SELECT syntax, so it is now possible to prevent data loss when rollback an updated database (Bug #10892)
- Updated API of getInstructionFields() and getInstructionWhere()
- It is now possible to prevent updateDatabase() of overwriting the old schema file
- alterDatabaseTables() first add new tables, then remove the old one. it is necessary to save table data before a remove
- updateDatabase() was aborting, under certain conditions, when <was> was not found (Bug #11600)
- Now validating database definition when reverse engineering (Bug #11604)
- createDatabase() has a new parameter that is passed to the database driver to set some options like table engine
- Foreign Keys support
- It is now possible to assign to a column the value of another column, of the same table, when inserting data
- Fixed the HTML etities issue when parsing a schema file (Bug #11676)
- XML Documentation, XSD and DST updated to show/expect the attributes in a unique order. Writer and parsers was also updated to handle the attributes in that some order. That said Parser and Parser2 must have the exactly same output for a given XML
- Except for table fields, all other database elements are being initialized with all its attributes, no matter if those attributes are present on the XML or not
- Many bugs fixed in Parser2, that was not creating a valid database definition
- Introduced attribute "fixed" of table field declaration
- validateIndex() is now checking whether a index has fields
- Validate is not returning MDB2_OK instead of boolean true
- XML Documentation and schema validators revised and updated
open todo items:
- Clean up output of getDefinitionFromDatabase(). Sync it with Parser and Parser2.
- Automatically load reserved keywords
- Make MDB2_Schema loadable via MDB2_Driver_Common::loadModule() (Bug #8270)
- Allow simple if statements that mean that anything enclosed is only executed
if it meets certain criterias based on that version number (or some other
variable). This would enable people to add DML statements that are only
executed when updating from a specific version.
- Modularize Writer code or remake it
- Add specific error codes for Validate class
- Add support for ORDER clauses on UPDATEs (to resolve the duplicate key
problem)
- Update description.schema.xml
- Create unit test for comparedefinitions()
- Create unit test for initializetable()
- Create unit test to compare the expected array definition with what is parsed
- Improve validateDataFieldValue() to validate <column>
- Provide more info on MDB2_Schema_Validate errors (output parsed value and expected value)
- Views support
- Fulltext index support0.7.20.7.2betabeta2007-04-07BSD License- Allow options to be passed in when creating tables (Bug #10278)
- Existence of a single index results in no further index creation (Bug #10296)
- MDB2_Schema::createTableIndexes() ignores indexes (Bug #10285)
- column identifiers quoting problem (Bug #10195)
- Handle 'scale' value in DECIMAL field definition (Bug #10475)
- fixed phpdoc comment for validateDataField()
- all primary keys are given an index name of "primary" (Bug #10457)
- example.php should echo xml when no filename is given (Bug #10226)
open todo items:
- Make MDB2_Schema loadable via MDB2_Driver_Common::loadModule() (Bug #8270)
- Add ability to define variables inside the schema (like a version number)
- Allow simple if statements that mean that anything enclosed is only executed
if it meets certain criterias based on that version number (or some other
variable). This would enable people to add DML statements that are only
executed when updating from a specific version.
- Modularize Writer code or remake it
- Add specific error codes for Validate class
- Add support for ORDER clauses on UPDATEs (to resolve the duplicate key
problem)
- Update description.schema.xml
- Document how to use the API
- Create unit test for comparedefinitions()
- Create unit test for initializetable()
- Create unit test to compare the expected array definition with what is parsed
- HTML entities aren't being parsed correctly
- Improve validateDataFieldValue() to validate <column>
- Provide more info on MDB2_Schema_Validate errors (output parsed value and expected value)
- Views support
- Foreign keys support
- Fulltext index support0.7.10.7.1betabeta2007-02-21BSD License- Package converted to version 2
- compareDefinition() was trying to update non-changing id field (Bug #8820)
- for a moment <default> should be always parsed as string, no matter the field
type. this behavior may change in the future.
- undefined method MDB2_Schema::quoteIdentifier() (Bug #9172)
- added support for explicit NULL (<null></null>)
- <value></value> is now correctly being parsed as an empty string
- fixed internal bug in Parser that was introduced in revision 1.46 (Bug #9435)
- MDB2_Schema_Parser::setData() has been removed
- MDB2_Schema_Validate::validateDataField() is validating field data again
(Bug #9181)
- updated reserved keywords of ibase
- updated XML Schema documentation
- updated XML Schema example
- added a new test case to isBoolean() (empty string)
- released the very first approach of the new parser that makes usage of
XML_Serializer (alternative parser)
open todo items:
- Make MDB2_Schema loadable via MDB2_Driver_Common::loadModule() (Bug #8270)
- Add ability to define variables inside the schema (like a version number)
- Allow simple if statements that mean that anything enclosed is only executed
if it meets certain criterias based on that version number (or some other
variable). This would enable people to add DML statements that are only
executed when updating from a specific version.
- Modularize Writer code or remake it
- Add specific error codes for Validate class
- Add support for ORDER clauses on UPDATEs (to resolve the duplicate key
problem)
- Update description.schema.xml
- Document how to use the API
- Create unit test for comparedefinitions()
- Create unit test for initializetable()
- Create unit test to compare the expected array definition with what is parsed
- HTML entities aren't being parsed correctly
- Add optional support for scale in decimal fields
- Improve validateDataFieldValue() to validate <column>
- Provide more info on MDB2_Schema_Validate errors (output parsed value and expected value)
- Views support
- Foreign keys support
- Fulltext index support0.7.00.7.0betabeta2006-11-07BSD License- Improved INSERT support, added UPDATE and DELETE statements
- XML syntax redesigned to cover DML addictions
- Creation of an explicit NULL (<null></null>)
- various fixes to the DTD, including DML addictions
- XSD schema definition created
- Tests also output php version
- New example parse.php lets you check how a XML schema is stored
- Updated schema.xml to demo the DML support
- Documentation reformulated, also covering new XML syntax
- Improved demo script example.php, which now includes more actions and options
- Writer is returning an error when fopen() fails
- Writer has now its own error code
- Variable "seq" became "sequence" and "seq_name" became "sequence_name" in the
Parser
- Moved validation code out of the Parser into a new separate class called
Validation
- Fixed index handling in the Parser
- Refactored error handling in the Parser
- Removed variable "init_field", that wasn't being used, from the Parser
- Parser simulates only one level of recurssion, which means no more than
function-expression or vice-versa
- Fixed warning due to not checking with isset() in the Parser
- Fixed warning due to not checking with isset() in the Schema
- Typo fix (related to Bug #9024)
- Fixed createDatabase() that was trying to use a non-existant database that
was about to be created
- Simplified API for compareTableFieldsDefinitions() and
compareTableIndexesDefinitions()
- Rewritten some docblocks
- Added fold markers where missing
- Removed @static from non static methods
- Fixed several PEAR CS issues
- Added code for field/identifier quoting
- Ensure all identifiers are passed to quoteIdentifier() (Bug #8429)
open todo items:
- Make MDB2_Schema loadable via MDB2_Driver_Common::loadModule() (Bug #8270)
- Add ability to define variables inside the schema (like a version number)
- Allow simple if statements that mean that anything enclosed is only executed
if it meets certain criterias based on that version number (or some other
variable). This would enable people to add DML statements that are only
executed when updating from a specific version.
- Add support for recursive tag parsing. Currently only expression<->function
is supported but not expression-expression or function-function, although
recursion is already supported by the initializeTable() method
- Parser should be replaced for XML serializer ?
- Modularize Writer code or remake it
- Add specific error codes for Validate class
- Add support for ORDER clauses on UPDATEs (to resolve the duplicate key
problem)
- Update description.schema.xml
- Document how to use the API
- Create unit test for comparedefinitions()
- Create unit test for initializetable()
- Create unit test to compare the expected array definition with what is parsed
- HTML entities aren't being parsed correctly
- Add optional support for scale in decimal fields
- Implement "WHERE column IS NULL"
- Add ability to parse a "contents-only" XML dump
- Improve validateDataFieldValue() to validate <column>
- Provide more info on MDB2_Schema_Validate errors (output parsed value and expected value)0.6.00.6.0betabeta2006-07-23BSD License- added new XSL and CSS for xml schema file rendering (thx Bertrand)
- automatically generate <on> tags in <sequence> tags if there is a table with
the same name and a single column primary key
- do not dump default for LOB fields (Bug #7596)
- added support for "fixed" (needs more testing)
- phpdoc tweaks (thx Stoyan)
- fixed primary key emulation and some other minor issues in createTableIndexes() (Bug #7758)
- implemented skip_unreadable parameter in parseDatabaseDefinition() (Bug #7756)
- switched most array_key_exists() calls to !empty() to improve readability and performance
- fixed a few edge cases and potential warnings
- add method name as scope for call debug() calls
- use getValidTypes() from MDB2
- hint if dropping a primary constraint
- minor code tweak in how initialization data is set in the prepared statement
- force ISO-8859-1 when parsing XML due to different defaults for PHP4 and PHP5
- fixed handling for changes in indexes/constaints (Bug #7901)
- made forcing of defaults optional via the 'force_defaults' option (Request #8074)
- fixed several issues in the DTD (Bug #7890)
- set length and fixed for user_password in the test suite
- use nested transactions instead of normal transactions0.5.00.5.0betabeta2006-04-16BSD License- expanded reserved word handling
- fix LOB data dumping
- added overwrite support to writer class
- added comment for idxname_format setting to example
- added autoincrement and primary to the documentation and .xsl/.dtd
- if we cannot create the database, then assume it was created manually in the
test suite
- added option valid_types
- added option to set parser and writer class
- automatically let the installer set the API Version
- make sure that the Datatype module is loaded
- added valid_types property to determine if a given type is valid
schema and to set missing default values
- allow CURRENT_* as default in temporal types (bug #6416)
- improve test suite documentation
- added parseDatabaseDefinition() that can work with a file or array definition
- removed database_definition property and as a result reworked the API of most
methods *BC BREAK*
- added _dumpBoolean() in writer to better support variables in boolean fields
- allow method callbacks in MDB2_Schema_Writer::dumpDatabase (bug #7363)
- set error code in all raiseError() calls
- minor updates to the xml schema xsl and documentation (thx Bertrand)0.4.30.4.3betabeta2006-02-05BSD License- renamed "manager" property to "schema" for clarity in the testsuite
- fixed logic related to using a non existant previous schema name in updateDatabase()
open todo items:
- better handling for NULL values in the xml schema format0.4.20.4.2betabeta2006-01-14BSD License- added ability to dump sql instead of commiting it to the database in the example
- fix for bug in handling of boolean default values (bug #6397)
- default to notnull = false in the schema parser
- several fixes for database alterations (thx Matthias)
- default for autoincrement can be '0' or 0 in the parser
- set default 0 for autoincrement columns when reverse engineering a schema
- expect MDB2_ERROR_ALREADY_EXISTS when creating a database (bug #6481)
open todo items:
- better handling for NULL values in the xml schema format0.4.10.4.1betabeta2005-12-30BSD License- fixed bug in updateDatabase() when using a file as the previous schema
(bug was introduced in last release)
- fixed install roles for test files0.4.00.4.0betabeta2005-12-21BSD License- Silence a "error" when there is auto increment and a primary key index defined
on the same field, since auto increment implies a primary key
- support column length in create index (mysql only feature, but a nice touch,
emulating it with substring is not feasible though)
- use exec() for INSERT statement
- add extra debug info better use of the var_dump package if present in example
- fixed bug in verifyAlterDatabase() when checking table alterations (bug #5977)
- fixed typo in getTableConstraintDefinition() method name (removed additional "s") (bug #6054)
- expect and ignore MDB2_ERROR_NOT_FOUND when calling getTableConstraintDefinition()
and getTableIndexDefinition() (bug #6055)
- fixed typo in verifyAlterDatabase() (bug #6053)
- fixed typo in alterDatabaseSequences() (bug #6053)
- added test suite
- fixed issue in createDatabase() with portability fix case turned
- ensure that all primary/unique/foreign key handling is only in the contraint methods
- optionally allow schemas to be passed as an array to updateDatabase() (thx Matthias)0.3.00.3.0betabeta2005-10-10BSD LicenseWarning: this is an intermediary release to address php 4.4/5.0.5. Some of the
new features still need a bit more tweaking.
- use MDB2::factory() by default instead of MDB2::connect()
- added support for auto increment and primary key in schema.
- alterTable now needs the full definition to work (use getTableFieldDefinition
from Reverse module if you do not have a definition at hand) this eliminates the need
of the declaration part in the alterTable array.
- typo fix (bug #4620)
- php 4.4.x/5.0.5 fixes
- updated getTableFieldDefinition() call to accomodate API changes in MDB2
- MDB2_Schema has its own error class and error codes
- made it easier to add new database backend to the example
- better handle removing of indexes on renamed columns in alterDatabaseTables()
- use array_key_exists() instead of isset() where possible
- restructured changes array to fix bugs due to inconsistency in the handling of array keys
- added ability to disable query for the alterDatabase()/createDatabase() call
in updateDatabase(). this is useful to generate an RDBMS specific SQL file
using a custom debug callback
- prefer "true" and "false" over "1" and "0"
- an emty default tag now implies NULL for nullable columns and an empty string
for NOT NULL columns0.2.00.2.0betabeta2005-04-29BSD License- fixed error handling in updateDatabase()
- use MDB2::raiseError
- always copy schema file in updateDatabase()
- cosmetic fixes and tweaks
- improved overwrite to check via list*() before creating (bug #3857, #4101)
- updated MDB2 dependency
- fixed sequence dumping
- moved schema documentation, xml_reverse_engineering.php, MDB.dtd
and MDB.xls from MDB package
- added optional support for PEAR::XML_DTD based validation of schema files
- index can be defined on fields that dont explicity prohibit null values
- dont disable sequence dumping when implicit sequences have been found
- added code to support dumping of lobs (MDB2 really should move to streams)
- added writeInitialization() method (untested)
- is_boolean() => isBoolean() in parser (CS fix)
- added MDB2_Schema::factory()
- Parser: if set grab definition of a table from the strucure property if set0.1.00.1.0betabeta2005-04-07BSD LicenseThis is the first unbundled release of the old MDB2_Tools_Manager class that was
previously part of MDB2 until 2.0.0beta4. Due to the name change the package
does not collide with previous versions of MDB2.
Also the following changes were made in the process:
- fixed index alteration in the Manager (bug #3710)
- fixed bug in the Manager when upgrading a database that doesnt exist
- moved logic to compareDefinitions from the Manager into the Datatype module
- removed default_values property from the Manager
(the user will now need to set the proper defaults himself)
- do not require that not null fields have a default set in the Manager (bug #3997)
- use MDB2::raiseError() instead of MDB2_Driver_Common::raiseError()
- cleanedup connect() method to ensure that only MDB2 connections can be
assigned to the db property
- fixed bug in connect() method that prevented overwriting of options
- several cleanups and fixes to the example.php (used to be called
reverse_engineer_xml_schema.php)
- added apiVersion()
- use PEAR::raiseError()
MDB2_Schema-0.8.5/docs/examples/parse.php 100644 765 765 7735 11150346546 13276 |
// +----------------------------------------------------------------------+
//
// $Id: parse.php,v 1.4 2006/08/17 10:57:37 lsmith Exp $
//
#ini_set('include_path', '../../'.PATH_SEPARATOR.ini_get('include_path'));
#ini_set('include_path', '../../../MDB2'.PATH_SEPARATOR.ini_get('include_path'));
require_once 'MDB2.php';
$dsn = array(
'phptype' => 'mysql',
'username' => 'root',
'password' => '',
'hostspec' => 'localhost',
);
$options = array();
MDB2::loadFile('Schema');
$manager =& MDB2_Schema::factory($dsn, $options);
if (MDB2::isError($manager)) {
die($manager->getUserinfo());
}
$database_definition = $manager->parseDatabaseDefinitionFile('./schema.xml');
$manager->db->setOption('disable_query', true);
$manager->db->setOption('debug', true);
$manager->writeInitialization($database_definition);
?>
Packagesidintegertrue4true01nametext128trueunknownsummaryclobtruecreationdatefalsePRIMARYtrueidascendingid11namePEARsummaryPEAR Base Systemcreation2006-08-16id12nameMDB2summaryDatabase Abstraction Layercreation2006-09-03id13nameMDB2_SchemasummaryXML Based Database Schema Managercreationnowid14nameXML_ParsersummaryXML parsing class based on PHP's bundled expatcreation2005-09-24id77nameI am supposed to be deletedididMINUS10idEQUAL67
MDB2_Schema-0.8.5/docs/description.schema.xml 100644 765 765 24325 11150346546 14153
MDB2_SchemaMDB2_Schema self descriptionThis is non authoritative but self described10
databaseGeneral database/schema configurationIt is the root element of a MDB2 Schema, must contain at least 1 <table>
and eventually some <sequence>nametextDatabase name1createbooleanCreate new0=Use a previously installed database , 1=Create the specified database0overwritebooleanOverwrite previousOverwrite previously created structures ?0descriptiontextDatabase descriptionIgnored by the parsercommentstextFree commentsIgnored by the parser
tableDescribes each table of the databaseA child of <database>, must contain a <declaration> with at least 1
<field> and eventually some <index>.
<table> may also have a <initialization> with some <insert>nametext1Table nameShould be better taken as some NMTOKEN , use ASCII no space better.wastextTable previous namedescriptiontextTable descriptionIgnored by the parsercommentstextFree commentsIgnored by the parsername_index1nameIndicates that 2 tables should not have the same name within a database
fieldDescribes each field in a table
<field> as a child of <declaration> so grand-child of <table>
nametext1Field namewastextField previous nametypetext1Field typeValid types:
integer, text, boolean, date, timestamp, time, float, decimal, clob and blob.
defaulttextOptional default valuenotnullbooleanField requiredMust be set for fields belonging to an index (sql NOT NULL)0autoincrementbooleanField auto incrementsIt's a not null integer field with a primary key.
Not supported by all DBMS but may be emulated0unsignedbooleanUnsignedOnly for integer. Not supported by all DBMS0lengthintegerLengthSome types as "text" optionally offer it.descriptiontextField descriptionIgnored by the parsercommentstextFree commentsIgnored by the parsername_index1nameIndicates that 2 fields should not have the same name within a table
indexDescribes each index in a tablechild of <declaration> so grand-child of <table>nametext1Index namewastextIndex previous nameuniquebooleanIndex is uniqueThe combined value of the contained fields is unique0primarybooleanTable primary index0descriptiontextIndex descriptionIgnored by the parser, and not in 0.5.0 dtdcommentstextFree commentsIgnored by the parser, and not in 0.5.0 dtdname_index1nameIndicates that 2 indexes should not have the same name within a table
index_fieldDescribes what fields make an index in a table<field> as a child of <index>nametext1Referenced field nameThis should reference the name of some uncle <field>sortingtextField's order in the sortValid: ascending or descendingdescriptiontextindex field descriptionIgnored by the parsercommentstextFree commentsIgnored by the parser
insert_fieldDescribes each field in an insert for table initializationchild of <insert> from <initialization> so great-grand-child of <table>nametext1field nameThis should reference the name of some grand-uncle <field>valuetextfield valuedescriptiontextinsert field descriptionIgnored by the parsercommentstextFree commentsIgnored by the parser
sequenceDescribes each sequence of the databaseA child of <database> , may contain one <on>nametext1Sequence namewastextSequence previous namestartintegerSequence start valuedescriptiontextSequence descriptionIgnored by the parsercommentstextFree commentsIgnored by the parsername_index1nameIndicates that 2 sequences should not have the same name within a database
The schema description format is based on XML (eXtensible Markup Language). For those that are not familiar with it, XML is standard that specifies rules to define abstract data formats based on tagged text.
Like HTML (HyperText Markup Language), XML is also based on SGML (Standard Generalized Markup Language). SGML defines rules to structure data using special text tags.
SGML tags may be used to delimit data sections. Section begin tags are of the form <name attributes... > and end tags are of the form </name>. name is the name of the tag and attributes is a set of zero or more pairs of attribute names and the values associated with the respective tag.
XML is a little stricter in the way tags may be used. While with many SGML formats some end tags are optional, in XML end tags are always required. Also, when tag attributes are used, attribute values must be specified always between quotes. These XML requirements are usually known as well-formedness.
Another important detail about XML strictness is that tag names and attributes are case sensitive. This means that tags in upper case are distinct from tags in lower case.
Unlike a common (but mistaken) belief, XML is not meant just for describing data in documents that are meant to be displayed or printed. XML is a standard that defines rules for describing abstract data may be used to for any purpose.
Even though it may be used to schemas that may be displayed or printed, Metabase schema description format is meant to provide a way for developers to design their database schemas using a DBMS independent file format. Using this format, developers may describe relations and properties of tables, field, indexes, sequences, etc..
This format uses just a subset of the XML known as SML (Simplified Markup Language). SML formats complies with the same rules as any XML format but it does not use all its possibilities to make it simpler for users to write and understand the data. For instance, files written on SML do not use any tag attributes.
Metabase schema description format is also simpler to edit by hand because tags and constant data values should always be in lower case to save the user from holding frequently the keyboard shift key.
The Metabase schema description format lets the developers describe a set of database schema objects following the database objects hierarchy. This means that a database may contain tables and sequence objects, tables may contain fields and index objects and all these objects have their own attributes.
The definition of each database schema object contained within the begin and end tags of the respective container object. Therefore, the definition of each table and sequence has to be specified between the main database begin and end tags. Likewise, the definition of fields and indexes has to be specified between the respective table begin and end tags.
The properties of each schema object are also defined between the respective begin and end tags. The values of each property are also defined between the respective property being and end tags.
The values of the properties are subject of validation according to the type of each property and the context within which they are being defined.
Some properties define names of database schema objects. There are names that are accepted as valid for some DBMS that are not accepted by other DBMS. Metabase schema parser may optionally fail if such names are used to reduce the potential problems when using the same Metabase based application with different DBMS.
The schema object description tags are defined as follows:
The database tag should be always at the top of the schema object hierarchy. Currently it may contain the definition of two types of objects: table and sequence.
The database schema object may have the following properties:
name
(required)
Name of the database that is meant to be created when it is installed for the first time.
Default: none
create
Boolean flag that indicates whether the database manager class should create the specified database or use a previously installed database of the same name.
This property may have to be set to false if you are splitting your database definition in multiple schema description files and only the installation of the first description file is supposed to lead to the actual database creation operation.
Another circumstance on which this property may have to be set to false is when the DBMS driver does not support database creation or if this operation requires special database administrator permissions that may not be available to the database user.
Default:false
overwrite
Boolean flag that indicates whether the database manager class should overwrite previously created structures.
Default:false
charset
Charset/Encoding of database.
Default:none
description
Free text property meant for describing the purpose of the database. This field is not processed by the schema parser. It may contain text or other XML well formed tags that may be useful for embedding additional data structures for documentation applications or other purposes.
Default: none
comments
Additional database comments. This field is not processed by the schema parser. It may contain text or other XML well formed tags that may be useful for embedding additional data structures for documentation applications or other purposes.
The table is one of the main database schema objects. It may be used in a schema description multiple times, once per each table that is contained the database being described.
The table object definition may contain the declaration and initialization sections besides the properties. The table schema object may have the following properties:
name
(required)
Name of the table.
Default: none
was
Name that the table had before the last time it was renamed. This property is only meant to be used when the database is being upgraded and the table is meant to be renamed.
Beware that if this property is not specified and the name is changed, that is intended as if it is meant to drop the table with the previous name and create a new table without keeping the data that was previously stored in the table.
Default: table name
description
Free text property meant for describing the purpose of the table. This field is not processed by the schema parser. It may contain text or other XML well formed tags that may be useful for embedding additional data structures for documentation applications or other purposes.
Default: none
comments
Additional table comments. This field is not processed by the schema parser. It may contain text or other XML well formed tags that may be useful for embedding additional data structures for documentation applications or other purposes.
declaration is one of the sections that is part of the table definition. This section is required because it must contain the definition of the table field and index objects.
field
field is one of the types of table definition object. It should be specified within the table declaration section for each field that the table should contain.
The field schema object may have the following properties:
name (required)
Name of the field.
Default: none
was
Name that the field had before the last time it was renamed. This property is only meant to be used when the database is being upgraded and the field is meant to be renamed.
Default: field name
type (required)
Type of the field. Valid type values are: integer, text, boolean, date, timestamp, time, float, decimal, clob and blob.
Default: none
fixed
Boolean flag property that specifies whether the table field should have a fixed length.
Default:false
default
Default value for the field. The allowed values depend on the type of the field. If this property is not specified the default value is assumed to be NULL. If there is a table index on the field being declared, the default value must be specified because indexes can not be created on table fields with NULL values.
Notice that some low end DBMS do not support specifying default values in the field definition. Make sure that the you either specify all the values for each new row that is inserted in the tables or that the DBMS actually supports default values.
Only some DBMS support default values for large object fields. For this reason it is not allowed to specify default values on the definition of this type of field.
Default: depends on field type
notnull
Boolean flag property that specifies whether the table field should be created with the constraint NOT NULL. As it suggests, this implies that it is not allowed to set this field value with NULL. The parser does not allow that an index is declared on a field that is not declared with the notnull flag property.
Default:false
autoincrement
Boolean flag property that specifies whether the field should be an auto incrementing not null integer field with a primary key. Note that some DBMS do not support auto increment natively in which case this is emulated with a trigger that updates a sequence.
Default:false
unsigned
Boolean flag property that specifies whether an integer field should be declared as unsigned integer. Note that some DBMS do not support unsigned integer fields. In such case the DBMS driver will ignore this property but it issues a warning.
Default:false
length
Unsigned integer property that specifies the length of a text. If this property is specified the text field may not have a longer length. Text values shorter than the length are not padded. If this property is not specified the length limit is determined by the DBMS.
Default: none
description
Free text property meant for describing the purpose of the field. This field is not processed by the schema parser. It may contain text or other XML well formed tags that may be useful for embedding additional data structures for documentation applications or other purposes.
Default: none
comments
Additional field comments. This field is not processed by the schema parser. It may contain text or other XML well formed tags that may be useful for embedding additional data structures for documentation applications or other purposes.
index is another type of table definition object. It should also be specified within the table declaration section for each field that the table should contain.
The index schema object may have the following properties:
name (required)
Name of the index.
Only some DBMS support indexes on large object fields. For this reason it is not allowed to specify a large object field for indexes.
Default: none
was
Name that the index had before the last time it was renamed. This property is only meant to be used when the database is being upgraded and the field is meant to be renamed.
Default: index name
unique
Boolean flag property that specifies whether the combination of the values of the index fields on each row of the table should unique.
Default:false
primary
Boolean flag property that specifies whether the combination of the values of the index fields on each row of the table should be a primary key.
Default:false
index field
field is a section that is part of the table index declaration. It should be used once per each field on which the index should be created.
The index field declaration may have the following properties:
name (required)
Name of the field on which the index should be created.
Default: none
sorting
Type of field sorting that should be assumed when the index is created. On DBMS that support index sorting, queries that search tables on the fields specified by the given index may execute faster if the specified sorting type is chosen adequately. DBMS that do not support index sorting will ignore this property.
Valid sorting types are ascending and descending.
Default:ascending
length
The length attribute is only supported by the MySQL and MySQLi drivers.
Expects an integer.
Default: none
Example
<index>
<name>users_index</name> <field>
<name>id</name> <sorting>ascending</sorting>
</field>
</index>
foreign
foreign was added in Schema version 0.7.3. [description here]
The foreign schema object may have the following properties:
name (required)
Name of the foreign key.
Default: none
was
Name that the foreign key had before the last time it was renamed. This property is only meant to be used when the database is being upgraded and the field is meant to be renamed.
Default: foreign key name
match
Allow the litereal string values: full, partial or simple.
Default: none
ondelete
Allow the litereal string values: cascade, set null, set default, restrict or no action.
Default: none
onupdate
Allow the litereal string values: cascade, set null, set default, restrict or no action.
Default: none
deferrable
Boolean flag property.
Default:false
initiallydeferred
Boolean flag property.
Default:false
foreign field
foreign field should be used once per each field on which the foreign key should be created. Allow a string value indicating a field name.
foreign references
references is a section that is part of the table foreign key declaration.
This section is optional. If it is absent, it is assumed that the referenced key is the primary key of referenced table.
The foreign references declaration may have the following properties:
table (required)
Name of the table being referenced.
Default: none
field
Name of the field being referenced. It should be used once per each field on which the foreign key should reference.
The number and types of fields in the referenced key must match those of the foreign key.
initialization is another section that is part of the table definition. This section is optional and may contain the definition of actions that should be executed when installing the database for the first time. update and delete was added in Schema version 0.7.0.
The available actions, in the execution order, are:
insert
insert is a table initialization command that specifies the values of the fields of rows that should be inserted in the respective table after the database is created for the first time.
The insert initialization object do not have any property.
insert field
field is a section that is part of the table insert initialization. It should be used once per each field which should be filled with data.
It may have only the property name.
One, and only one, of the following objects should be used to specify the initial data:
null
NULL value. Anything inside null will be ignored.
value
Plain text data.
column
Take data from the specified column of the respective table.
function
Take the output of the specified DBMS function.
expression
Recursive structure capable of mixing all of the above objects.
When doing an insert missing fields are implicitly initialized by the DBMS with the respective default values.
Example
<insert>
<field>
<name>foo</name>
<value>1601</value>
</field>
<field>
<name>creation</name>
<function>
<name>NOW</name>
</function>
</field>
</insert>
insert select
select was added in Schema version 0.7.3 to acomplish the INSERT...SELECT syntax. It is optional and, when used, should be the only child of insert.
It may have only the property table that designates the table name in the select statement.
insert select field
The insert select field object is defined exactly the same way as insert field. Here name goes to the fields portion of the insert statement and the next property goes to the fields portion of the select statement
insert select where
The insert select where object, that is not required, must contain only one expression object.
In that case the expression object usually links operants by logical operators like AND, OR and others.
update
update is a table initialization command that replaces the values of the fields of rows, matched by a condition, in the respective table after the database is created for the first time.
The update initialization object do not have any property.
update field
The update field object is defined exactly the same way as insert field
update where
The update where object, that is not required, must contain only one expression object.
In that case the expression object usually links operants by logical operators like AND, OR and others.
delete is a table initialization command that removes rows, matched by a condition, in the respective table after the database is created for the first time.
The delete command definition only contains one more where section used to select the rows to be deleted.
The delete initialization object do not have any property.
delete where
The delete where object must contain only one expression object.
In that case the expression object usually links operants by logical operators like AND, OR and others.
The sequence is another main database schema object. It may be used in a schema description multiple times, once per each sequence that is contained the database being described.
A sequence is an object that only contains an integer value. A sequence value is automatically incremented after every time it is fetch the next sequence value. The fetch and increment actions constitute an atomic operation. This means that if two concurrent accesses to the database fetch the next sequence value, they will always different values.
Sequences are useful to generate integer numbers that may be used to store in fields that must contain unique numbers.
The sequence object definition may contain one on section besides the properties. The sequence schema object may have the following properties:
name
(required)
Name of the sequence.
Default: none
was
Name that the sequence had before the last time it was renamed. This property is only meant to be used when the database is being upgraded and the sequence is meant to be renamed.
Default: sequence name
start
Integer property that specifies the value that the sequence will return when it is fetched the next sequence value.
Default:1
description
Free text property meant for describing the purpose of the sequence. This field is not processed by the schema parser. It may contain text or other XML well formed tags that may be useful for embedding additional data structures for documentation applications or other purposes.
Default: none
comments
Additional sequence comments. This field is not processed by the schema parser. It may contain text or other XML well formed tags that may be useful for embedding additional data structures for documentation applications or other purposes.
Default: none
sequence on
The sequence ontablefield section specifies a table field on which the sequence value should be synchronized.
This information is meant to be used only by the database manager class when it is added a sequence later after the database has been installed for the first time. If the sequence on is specified, the database manager class will override the sequence start value with a value that is higher than the highest value in the specified field table. Therefore, the specified field table type must be integer.
The variable tag is not meant to define any database schema object but rather a means to replace property values with variables defined at parsing time.
For instance, if you have several tables that store user names in text fields with the same length limit, instead of hard coding the length value in all field definitions, you may use a variable reference. The parser will replace variable references found in property definitions by the text values of the respective values passed to the parser.
The parser will issue an error if it find a reference for a variable that is not defined.