v5:dictionary:structure:introduction
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| v5:dictionary:structure:introduction [2016/04/09 21:30] – mnewnham | v5:dictionary:structure:introduction [2021/08/26 10:11] (current) – typos peterdd | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| **From Version 5.21.0-beta-2** | **From Version 5.21.0-beta-2** | ||
| == Reference == | == Reference == | ||
| - | [[v5: | + | [[v5: |
| [[v5: | [[v5: | ||
| [[v5: | [[v5: | ||
| [[v5: | [[v5: | ||
| [[v5: | [[v5: | ||
| + | [[v5: | ||
| + | [[v5: | ||
| </ | </ | ||
| ===== Description ===== | ===== Description ===== | ||
| From ADOdb Version 5.21, A new method of managing changes to the schema has been added. This method is called // | From ADOdb Version 5.21, A new method of managing changes to the schema has been added. This method is called // | ||
| - | In Structured schema management, the elements that can be modified through the dictionary management routines such as [[v5: | + | In Structured schema management, the elements that can be modified through the dictionary management routines such as [[v5: |
| These objects can then be easily stored through the use of technologies such as JSON, which can easily be manipulated through 3rd party tools and reprocessed. | These objects can then be easily stored through the use of technologies such as JSON, which can easily be manipulated through 3rd party tools and reprocessed. | ||
| - | Each table, and element of a table (such as a column or index) is represented by a PHP object called a // | + | Each table and element of a table (such as a column or index) is represented by a PHP object called a // |
| ===== Construction Of The Structure ===== | ===== Construction Of The Structure ===== | ||
| Line 37: | Line 39: | ||
| The **// | The **// | ||
| + | |||
| + | ===== Processing The MetaObjectStructure ===== | ||
| + | |||
| + | The structure is not automatically sent to createTableSql, | ||
| + | |||
| + | In this example, we create a table ' | ||
| + | |||
| + | <code php> | ||
| + | $dict = newDataDictionary($db); | ||
| + | $t = new metaObjectStructure($dict, | ||
| + | /* | ||
| + | * Make sure the table is transactional in MySQL | ||
| + | */ | ||
| + | $t-> | ||
| + | |||
| + | /* | ||
| + | * Add the column | ||
| + | */ | ||
| + | $t-> | ||
| + | |||
| + | /* | ||
| + | * Now get the structure | ||
| + | */ | ||
| + | print_r($t); | ||
| + | </ | ||
| + | |||
| + | The following object is returned: | ||
| + | |||
| + | < | ||
| + | metaObjectStructure Object | ||
| + | ( | ||
| + | [type] => table | ||
| + | [value] => | ||
| + | [platform] => | ||
| + | [options] => Array | ||
| + | ( | ||
| + | ) | ||
| + | [attributes] => Array | ||
| + | ( | ||
| + | [0] => metaElementStructure Object | ||
| + | ( | ||
| + | [type] => table | ||
| + | [name] => test | ||
| + | [value] => ENGINE INNODB | ||
| + | [platform] => mysql | ||
| + | [action] => 0 | ||
| + | [attributes] => Array | ||
| + | ( | ||
| + | ) | ||
| + | ) | ||
| + | ) | ||
| + | [name] => test | ||
| + | [action] => 0 | ||
| + | [columns] => Array | ||
| + | ( | ||
| + | [COL1] => metaObjectStructure Object | ||
| + | ( | ||
| + | [type] => column | ||
| + | [value] => I | ||
| + | [platform] => | ||
| + | [options] => Array | ||
| + | ( | ||
| + | ) | ||
| + | [attributes] => Array | ||
| + | ( | ||
| + | ) | ||
| + | [name] => COL1 | ||
| + | [action] => 0 | ||
| + | ) | ||
| + | ) | ||
| + | ) | ||
| + | </ | ||
| + | |||
| + | We could JSON-encode it here and store it | ||
| + | |||
| + | <code php> | ||
| + | $j = json_encode($def) | ||
| + | /* | ||
| + | {" | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }], | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | */ | ||
| + | </ | ||
| + | ===== Processing The Structure ===== | ||
| + | A change to '' | ||
| + | |||
| + | <code php> | ||
| + | |||
| + | $sql = $dict-> | ||
| + | |||
| + | print_r($sql); | ||
| + | /* | ||
| + | * Returns: | ||
| + | Array | ||
| + | ( | ||
| + | [0] => CREATE TABLE test ( | ||
| + | COL1 I | ||
| + | )ENGINE INNODB | ||
| + | ) | ||
| + | */ | ||
| + | </ | ||
| + | |||
v5/dictionary/structure/introduction.1460230235.txt.gz · Last modified: (external edit)
