ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:dictionary:xmlschema

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
v5:dictionary:xmlschema [2016/01/13 02:06] – ↷ Page moved from dictionary:xmlschema to v5:dictionary:xmlschema mnewnhamv5:dictionary:xmlschema [2018/06/11 10:05] (current) – [Executing the Schema] function calls starting with lowercase (#426) dregad
Line 3: Line 3:
 <WRAP right box round 300px> <WRAP right box round 300px>
 ==See also== ==See also==
-[[axmls:axmls_functions|AXMLS Function Reference]]\\ +[[v5:axmls:axmls_functions|AXMLS Function Reference]]\\ 
-[[dictionary:data_dictionary|The Meta Functions]]\\+[[v5:dictionary:dictionary_index|The Meta Functions]]\\
 </WRAP> </WRAP>
  
 ===== Introduction ===== ===== Introduction =====
     
-Adodb-xmlschema, or AXMLS, is a set of classes that extends the ADOdb [[dictionary:data dictionary]] by processing XML formatted files and transforming them into ADOdb portable schema management commands. In simple terms:+Adodb-xmlschema, or AXMLS, is a set of classes that extends the ADOdb [[v5:dictionary:dictionary_index]] by processing XML formatted files and transforming them into ADOdb portable schema management commands. In simple terms:
  
   * 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:parseSchema()]] method, which converts the XML into an array of SQL statements. These statements can then be executed using the [[axmls:executeSchema()]] method.+  * The table can be created by processing the XML file with the [[v5:axmls:parseschema]] method, which converts the XML into an array of SQL statements. These statements can then be executed using the [[v5:axmls:executeschema]] method.
   * 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 151: Line 151:
  */  */
 $db = ADONewConnection( $platform ); $db = ADONewConnection( $platform );
-$db->Connect( $dbHost, $dbUser, $dbPassword, $dbName );+$db->connect( $dbHost, $dbUser, $dbPassword, $dbName );
  
 /* Use the database connection to create a new adoSchema object. /* Use the database connection to create a new adoSchema object.
Line 157: Line 157:
 $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->ParseSchema( $schemaFile ); +$sql = $schema->parseSchema( $schemaFile ); 
-$result = $schema->ExecuteSchema();+$result = $schema->executeSchema();
 </code> </code>
  
Line 169: Line 169:
 <code php> <code php>
 $db = ADONewConnection( 'mysql' ); $db = ADONewConnection( 'mysql' );
-$db->Connect( 'host', 'user', 'password', 'database' );+$db->connect( 'host', 'user', 'password', 'database' );
 </code> </code>
  
Line 178: Line 178:
 </code> </code>
  
-Third, call ParseSchema() to parse the schema and then ''executeSchema()'' to apply it to the database. You must pass ''parseSchema()'' the path and filename of your schema file.+Third, call parseSchema() to parse the schema and then ''executeSchema()'' to apply it to the database. You must pass ''parseSchema()'' the path and filename of your schema file.
  
 <code php> <code php>
-$schema->ParseSchema( $schemaFile );  +$schema->parseSchema( $schemaFile );  
-$schema->ExecuteSchema(); +$schema->executeSchema(); 
 </code> </code>
  
Line 192: Line 192:
 AXMLS consists of two parts: the **schema description**, or **DTD**, and the PHP class that manipulates and parses the schema. This document introduces the reader to many of the tools AXMLS provides to manage and manipulate a schema. AXMLS consists of two parts: the **schema description**, or **DTD**, and the PHP class that manipulates and parses the schema. This document introduces the reader to many of the tools AXMLS provides to manage and manipulate a schema.
 ==== 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:continueonerror|ContinueOnError()]] method to specify whether or not database execution should attempt to continue if an error occurs.+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:continueonerror|continueOnError()]] method to specify whether or not database execution should attempt to continue if an error occurs.
  
 **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.
Line 200: Line 200:
  
 // Inline Execution // Inline Execution
-$schema->ContinueOnError( TRUE ); +$schema->continueOnError( TRUE ); 
-$schema->ExecuteInline( TRUE ); +$schema->executeInline( TRUE ); 
-$schema->ParseSchemaFile( "schema.xml" );+$schema->parseSchemaFile( "schema.xml" );
 </code> </code>
  
Line 212: Line 212:
 // Post Execution (default) // Post Execution (default)
 $schema->executeInline( FALSE ); $schema->executeInline( FALSE );
-$schema->ParseSchemaFile( "schema.xml" ); +$schema->parseSchemaFile( "schema.xml" ); 
-$schema->ExecuteSchema();+$schema->executeSchema();
 </code> </code>
  
Line 220: Line 220:
 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'll be less likely to conflict with other applications that share the database. AXMLS's [[axmls:setprefix|setPrefix()]] method provides this capability.+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'll be less likely to conflict with other applications that share the database. AXMLS's [[v5:axmls:setprefix|setPrefix()]] method provides this capability.
  
 <code php> <code php>
Line 230: Line 230:
 ==== Getting at the SQL ==== ==== Getting at the SQL ====
  
-AXMLS provides several tools for accessing the SQL created by the schema parser. Calling [[axmls:printSql()]] returns the parsed SQL in HTML, text, or PHP array format. Calling [[axmls:saveSql()]] saves the parsed SQL to the specified file.+AXMLS provides several tools for accessing the SQL created by the schema parser. Calling [[v5:axmls:printsql]] returns the parsed SQL in HTML, text, or PHP array format. Calling [[v5:axmls:savesql]] saves the parsed SQL to the specified file.
  
 <code php> <code php>
v5/dictionary/xmlschema.1452647178.txt.gz · Last modified: 2017/04/21 11:27 (external edit)