|
Moodle
2.2.1
http://www.collinsharper.com
|
This class represent one XMLDB structure. More...


Public Member Functions | |
| __construct ($name) | |
| getPath () | |
| getVersion () | |
| & | getTable ($tablename) |
| & | findTableInArray ($tablename) |
| orderTables () | |
| & | getTables () |
| setVersion ($version) | |
| addTable (&$table, $after=NULL) | |
| deleteTable ($tablename) | |
| setTables (&$tables) | |
| arr2xmldb_structure ($xmlarr) | |
| calculateHash ($recursive=false) | |
| xmlOutput () | |
| getTableUses ($tablename) | |
| getFieldUses ($tablename, $fieldname) | |
| getKeyUses ($tablename, $keyname) | |
| getIndexUses ($tablename, $indexname) | |
| getAllErrors () | |
Data Fields | |
| $path | |
| $version | |
| $tables | |
This class represent one XMLDB structure.
Definition at line 29 of file xmldb_structure.php.
| __construct | ( | $ | name | ) |
Creates one new xmldb_structure
Reimplemented from xmldb_object.
Definition at line 38 of file xmldb_structure.php.
| addTable | ( | &$ | table, |
| $ | after = NULL |
||
| ) |
Add one table to the structure, allowing to specify the desired order If it's not specified, then the table is added at the end.
Calculate the previous and next tables
Set current table previous and next attributes
Some more attributes
Add the new table
Reorder the whole structure
Recalculate the hash
We have one new table, so the structure has changed
Definition at line 115 of file xmldb_structure.php.

| arr2xmldb_structure | ( | $ | xmlarr | ) |
Load data from XML to the structure
Debug the structure traverse_xmlize($xmlarr); //Debug print_object ($GLOBALS['traverse_array']); //Debug $GLOBALS['traverse_array']=""; //Debug
Process structure attributes (path, comment and version)
Iterate over tables
Perform some general checks over tables
Check tables names are ok (lowercase, a-z _-)
Check previous & next are ok (duplicates and existing tables)
Order tables
Set some attributes
Definition at line 197 of file xmldb_structure.php.

| calculateHash | ( | $ | recursive = false | ) |
This function calculate and set the hash of one xmldb_structure
Definition at line 289 of file xmldb_structure.php.


| deleteTable | ( | $ | tablename | ) |
Delete one table from the Structure
Look for prev and next table
Change their previous and next attributes
Delete the table
Reorder the tables
Recalculate the hash
We have one deleted table, so the structure has changed
Definition at line 160 of file xmldb_structure.php.

| & findTableInArray | ( | $ | tablename | ) |
Returns the position of one table in the array.
Definition at line 74 of file xmldb_structure.php.

| getAllErrors | ( | ) |
This function will return all the errors found in one structure looking recursively inside each table. Returns an array of errors or false
First the structure itself
Delegate to tables
Add them to the errors array
Return decision
Definition at line 491 of file xmldb_structure.php.

| getFieldUses | ( | $ | tablename, |
| $ | fieldname | ||
| ) |
This function returns the number of uses of one field inside a whole xmldb_structure. Useful to detect if the field must be locked. Return false if no uses are found.
Check if any key in the table is using it
Check if any index in the table is using it
Check if some foreign key in the whole structure is using it By comparing the reftable and refields with the field)
Return result
Definition at line 375 of file xmldb_structure.php.

| getIndexUses | ( | $ | tablename, |
| $ | indexname | ||
| ) |
This function returns the number of uses of one index inside a whole xmldb_structure. Useful to detect if the index must be locked. Return false if no uses are found.
Nothing to check, beause indexes haven't uses! Leave it here for future checks...
Return result
Definition at line 471 of file xmldb_structure.php.
| getKeyUses | ( | $ | tablename, |
| $ | keyname | ||
| ) |
This function returns the number of uses of one key inside a whole xmldb_structure. Useful to detect if the key must be locked. Return false if no uses are found.
Check if some foreign key in the whole structure is using it (by comparing the reftable and reffields with the fields in the key)
Return result
Definition at line 432 of file xmldb_structure.php.

| getPath | ( | ) |
Returns the path of the structure
Definition at line 48 of file xmldb_structure.php.
| & getTable | ( | $ | tablename | ) |
Returns one xmldb_table
Definition at line 62 of file xmldb_structure.php.


| & getTables | ( | ) |
Returns the tables of the structure
Definition at line 100 of file xmldb_structure.php.

| getTableUses | ( | $ | tablename | ) |
This function returns the number of uses of one table inside a whole XMLDStructure. Useful to detect if the table must be locked. Return false if no uses are found.
Check if some foreign key in the whole structure is using it (by comparing the reftable with the tablename)
Return result
Definition at line 340 of file xmldb_structure.php.

| getVersion | ( | ) |
Returns the version of the structure
Definition at line 55 of file xmldb_structure.php.
| orderTables | ( | ) |
This function will reorder the array of tables
Definition at line 87 of file xmldb_structure.php.


| setTables | ( | &$ | tables | ) |
Set the tables
Definition at line 190 of file xmldb_structure.php.

| setVersion | ( | $ | version | ) |
Set the structure version
Definition at line 107 of file xmldb_structure.php.

| xmlOutput | ( | ) |
This function will output the XML text for one structure
Now the tables
Definition at line 310 of file xmldb_structure.php.
| $path |
Definition at line 31 of file xmldb_structure.php.
| $tables |
Definition at line 33 of file xmldb_structure.php.
Definition at line 32 of file xmldb_structure.php.