v5:axmls:axmls_index
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
v5:axmls:axmls_index [2016/01/13 03:47] – created mnewnham | v5:axmls:axmls_index [2020/01/13 15:52] (current) – Remove separator line dregad | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <WRAP right box> | ||
+ | [[v5: | ||
+ | </ | ||
======= ADOdb-xmlschema ====== | ======= ADOdb-xmlschema ====== | ||
- | ~~NOTOC~~ | + | |
<WRAP right box round 300px> | <WRAP right box round 300px> | ||
==See also== | ==See also== | ||
- | [[axmls: | + | [[v5:axmls: |
- | [[dictionary: | + | [[v5:dictionary:dictionary_index|The Meta Functions]]\\ |
</ | </ | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | Adodb-xmlschema, | + | Adodb-xmlschema, |
* An XML file contains all of the definitions required to create a table, the associated columns, indexes and constraints. | * An XML file contains all of the definitions required to create a table, the associated columns, indexes and constraints. | ||
- | * The table can be created by processing the XML file with the [[axmls: | + | * The table can be created by processing the XML file with the [[v5:axmls: |
* That XML file can be used **unmodified** against any database supported by ADOdb. | * That XML file can be used **unmodified** against any database supported by ADOdb. | ||
* Any modifications to the table can be enabled by simply modifying the XML file, and re-executing the XML load command. The ADOdb Meta Functions take care of any processing required to apply those changes to the table. | * Any modifications to the table can be enabled by simply modifying the XML file, and re-executing the XML load command. The ADOdb Meta Functions take care of any processing required to apply those changes to the table. | ||
Line 26: | Line 29: | ||
</ | </ | ||
===== Installation ===== | ===== Installation ===== | ||
- | This feature is included in the standard release | + | This feature is included in the standard release. |
===== Using AXMLS in Your Application ===== | ===== Using AXMLS in Your Application ===== | ||
There are two steps involved in using AXMLS in your application: | There are two steps involved in using AXMLS in your application: | ||
Line 36: | Line 39: | ||
<?xml version=" | <?xml version=" | ||
<schema version=" | <schema version=" | ||
- | |||
<table name=" | <table name=" | ||
- | <desc>A typical users table for our application.</ | + | <descr>A typical users table for our application.</ |
<field name=" | <field name=" | ||
< | < | ||
< | < | ||
< | < | ||
- | </ | + | </ |
- | | + | |
<field name=" | <field name=" | ||
- | | ||
<index name=" | <index name=" | ||
< | < | ||
Line 53: | Line 53: | ||
</ | </ | ||
</ | </ | ||
- | | ||
<sql> | <sql> | ||
< | < | ||
Line 62: | Line 61: | ||
</ | </ | ||
- | Let's take a detailed look at this schema. The opening ''<? | + | Let's take a detailed look at this schema. The opening ''<? |
<code xml> | <code xml> | ||
Line 75: | Line 74: | ||
<code xml> | <code xml> | ||
<table name=" | <table name=" | ||
- | + | | |
- | | + | |
<field name=" | <field name=" | ||
< | < | ||
Line 82: | Line 80: | ||
< | < | ||
</ | </ | ||
- | | ||
<field name=" | <field name=" | ||
- | | ||
</ | </ | ||
</ | </ | ||
Line 90: | Line 86: | ||
This table is called " | This table is called " | ||
- | * The description is optional, and is currently | + | * The description is optional, and is currently only for your own information; |
* The first < | * The first < | ||
* The second < | * The second < | ||
Line 101: | Line 97: | ||
<table name=" | <table name=" | ||
... | ... | ||
- | | ||
<index name=" | <index name=" | ||
< | < | ||
< | < | ||
< | < | ||
- | </ | + | </ |
- | | + | |
</ | </ | ||
</ | </ | ||
Line 119: | Line 113: | ||
<sql> | <sql> | ||
< | < | ||
- | < | + | < |
- | < | + | < |
</ | </ | ||
</ | </ | ||
Line 150: | Line 144: | ||
/* Start by creating a normal ADODB connection. | /* Start by creating a normal ADODB connection. | ||
*/ | */ | ||
- | $db = ADONewConnection( $platform ); | + | $db = ADONewConnection($platform); |
- | $db->Connect( $dbHost, $dbUser, $dbPassword, | + | $db->connect($dbHost, $dbUser, $dbPassword, |
/* Use the database connection to create a new adoSchema object. | /* Use the database connection to create a new adoSchema object. | ||
*/ | */ | ||
- | $schema = new adoSchema( $db ); | + | $schema = new adoSchema($db); |
- | /* Call ParseSchema() to build SQL from the XML schema file. | + | /* Call parseSchema() to build SQL from the XML schema file. |
- | * Then call ExecuteSchema() to apply the resulting SQL to | + | * Then call executeSchema() to apply the resulting SQL to |
* the database. | * the database. | ||
*/ | */ | ||
- | $sql = $schema-> | + | $sql = $schema-> |
- | $result = $schema-> | + | $result = $schema-> |
</ | </ | ||
Line 168: | Line 162: | ||
<code php> | <code php> | ||
- | $db = ADONewConnection( | + | $db = ADONewConnection($platform); |
- | $db->Connect( ' | + | $db->connect($dbHost, $dbUser, $dbPassword, $dbName); |
</ | </ | ||
Line 175: | Line 169: | ||
<code php> | <code php> | ||
- | $schema = new adoSchema( $db ); | + | $schema = new adoSchema($db); |
</ | </ | ||
- | Third, call ParseSchema() to parse the schema and then '' | + | Third, call parseSchema() to parse the schema and then '' |
<code php> | <code php> | ||
- | $schema-> | + | $schema-> |
- | $schema-> | + | $schema-> |
</ | </ | ||
Line 192: | Line 186: | ||
AXMLS consists of two parts: the **schema description**, | AXMLS consists of two parts: the **schema description**, | ||
==== Executing the Schema ==== | ==== Executing the Schema ==== | ||
- | AXMLS provides two different methods for applying the SQL resulting from a parsed schema to the database: **inline execution** and **post execution**. Use the [[axmls: | + | AXMLS provides two different methods for applying the SQL resulting from a parsed schema to the database: **inline execution** and **post execution**. Use the [[v5:axmls: |
**Inline Execution** applies each schema entity to the database immediately after that entity is parsed. I.e., the first table is read from the schema and applied to the database, then the second table, etc. | **Inline Execution** applies each schema entity to the database immediately after that entity is parsed. I.e., the first table is read from the schema and applied to the database, then the second table, etc. | ||
<code php> | <code php> | ||
- | $schema = new adoSchema( $this-> | + | $schema = new adoSchema($this-> |
// Inline Execution | // Inline Execution | ||
- | $schema-> | + | $schema-> |
- | $schema-> | + | $schema-> |
- | $schema-> | + | $schema-> |
</ | </ | ||
Line 208: | Line 202: | ||
<code php> | <code php> | ||
- | $schema = new adoSchema( $this-> | + | $schema = new adoSchema($this-> |
// Post Execution (default) | // Post Execution (default) | ||
- | $schema-> | + | $schema-> |
- | $schema-> | + | $schema-> |
- | $schema-> | + | $schema-> |
</ | </ | ||
Line 220: | Line 214: | ||
Upgrading a database is as simple as creating one. To upgrade an existing database to a new version of a schema, simply parse and execute the schema as above. AXMLS will automatically upgrade all tables and indices to match those provided in the schema. | Upgrading a database is as simple as creating one. To upgrade an existing database to a new version of a schema, simply parse and execute the schema as above. AXMLS will automatically upgrade all tables and indices to match those provided in the schema. | ||
==== Object Prefixing==== | ==== Object Prefixing==== | ||
- | In a world of pluggable and reusable code, multiple applications often coexist in a single database. Object prefixes allow you to create a namespace for your application. For example, an application called Tackle might want to prefix all its tables and objects with **tackle_** so they' | + | In a world of pluggable and reusable code, multiple applications often coexist in a single database. Object prefixes allow you to create a namespace for your application. For example, an application called Tackle might want to prefix all its tables and objects with **tackle_** so they' |
<code php> | <code php> | ||
- | $schema = new adoSchema( $this-> | + | $schema = new adoSchema($this-> |
// Set the prefix for database objects (before parsing) | // Set the prefix for database objects (before parsing) | ||
- | $schema-> | + | $schema-> |
</ | </ | ||
==== Getting at the SQL ==== | ==== Getting at the SQL ==== | ||
- | AXMLS provides several tools for accessing the SQL created by the schema parser. Calling [[axmls: | + | AXMLS provides several tools for accessing the SQL created by the schema parser. Calling [[v5:axmls: |
<code php> | <code php> | ||
- | $schema-> | + | $schema-> |
$schema-> | $schema-> | ||
- | print( $schema-> | + | print $schema-> |
- | print( $schema-> | + | print $schema-> |
$sql = $schema-> | $sql = $schema-> | ||
// Save SQL to file | // Save SQL to file | ||
- | $schema-> | + | $schema-> |
</ | </ | ||
As always, see the Class Documentation for detailed information about the methods. | As always, see the Class Documentation for detailed information about the methods. |
v5/axmls/axmls_index.1452653250.txt.gz · Last modified: 2017/04/21 11:51 (external edit)