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


Public Member Functions | |
| __construct ($name) | |
| addField (&$field, $after=NULL) | |
| addKey (&$key, $after=NULL) | |
| addIndex (&$index, $after=NULL) | |
| & | getFields () |
| & | getKeys () |
| & | getIndexes () |
| & | getField ($fieldname) |
| & | findFieldInArray ($fieldname) |
| orderFields () | |
| & | getKey ($keyname) |
| & | findKeyInArray ($keyname) |
| orderKeys () | |
| & | getIndex ($indexname) |
| & | findIndexInArray ($indexname) |
| orderIndexes () | |
| setFields ($fields) | |
| setKeys ($keys) | |
| setIndexes ($indexes) | |
| deleteField ($fieldname) | |
| deleteKey ($keyname) | |
| deleteIndex ($indexname) | |
| arr2xmldb_table ($xmlarr) | |
| calculateHash ($recursive=false) | |
| xmlOutput () | |
| addFieldInfo ($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) | |
| add_field ($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) | |
| Deprecated API ends here. | |
| addKeyInfo ($name, $type, $fields, $reftable=null, $reffields=null) | |
| add_key ($name, $type, $fields, $reftable=null, $reffields=null) | |
| Deprecated API ends here. | |
| addIndexInfo ($name, $type, $fields) | |
| add_index ($name, $type, $fields) | |
| Deprecated API ends here. | |
| getAllErrors () | |
Data Fields | |
| $fields | |
| $keys | |
| $indexes | |
This class represent one XMLDB table.
Definition at line 29 of file xmldb_table.php.
| __construct | ( | $ | name | ) |
Creates one new xmldb_table
Reimplemented from xmldb_object.
Reimplemented in XMLDBTable.
Definition at line 38 of file xmldb_table.php.
| add_field | ( | $ | name, |
| $ | type, | ||
| $ | precision = null, |
||
| $ | unsigned = null, |
||
| $ | notnull = null, |
||
| $ | sequence = null, |
||
| $ | default = null, |
||
| $ | previous = null |
||
| ) |
Deprecated API ends here.
This function will add one new field to the table with all its attributes defined
| string | name name of the field |
| string | type XMLDB_TYPE_INTEGER, XMLDB_TYPE_NUMBER, XMLDB_TYPE_CHAR, XMLDB_TYPE_TEXT, XMLDB_TYPE_BINARY |
| string | precision length for integers and chars, two-comma separated numbers for numbers and 'small', 'medium', 'big' for texts and binaries |
| string | unsigned XMLDB_UNSIGNED or null (or false) |
| string | notnull XMLDB_NOTNULL or null (or false) |
| string | sequence XMLDB_SEQUENCE or null (or false) |
| string | default meaningful default o null (or false) |
| string | previous name of the previous field in the table or null (or false) |
Definition at line 734 of file xmldb_table.php.


| add_index | ( | $ | name, |
| $ | type, | ||
| $ | fields | ||
| ) |
Deprecated API ends here.
This function will add one new index to the table with all its attributes defined
| string | name name of the index |
| string | type XMLDB_INDEX_UNIQUE, XMLDB_INDEX_NOTUNIQUE |
| array | fields an array of fieldnames to build the index over |
Definition at line 787 of file xmldb_table.php.


| add_key | ( | $ | name, |
| $ | type, | ||
| $ | fields, | ||
| $ | reftable = null, |
||
| $ | reffields = null |
||
| ) |
Deprecated API ends here.
This function will add one new key to the table with all its attributes defined
| string | name name of the key |
| string | type XMLDB_KEY_PRIMARY, XMLDB_KEY_UNIQUE, XMLDB_KEY_FOREIGN |
| array | fields an array of fieldnames to build the key over |
| string | reftable name of the table the FK points to or null |
| array | reffields an array of fieldnames in the FK table or null |
Definition at line 763 of file xmldb_table.php.


| addField | ( | &$ | field, |
| $ | after = NULL |
||
| ) |
Add one field to the table, allowing to specify the desired order If it's not specified, then the field is added at the end
Detect duplicates first
Calculate the previous and next fields
Set current field previous and next attributes
Some more attributes
Add the new field
Reorder the field
Recalculate the hash
We have one new field, so the table has changed
Definition at line 49 of file xmldb_table.php.


| addFieldInfo | ( | $ | name, |
| $ | type, | ||
| $ | precision = null, |
||
| $ | unsigned = null, |
||
| $ | notnull = null, |
||
| $ | sequence = null, |
||
| $ | enum = null, |
||
| $ | enumvalues = null, |
||
| $ | default = null, |
||
| $ | previous = null |
||
| ) |
TODO: Delete for 2.1 (deprecated in 2.0). Deprecated API starts here
Definition at line 709 of file xmldb_table.php.

| addIndex | ( | &$ | index, |
| $ | after = NULL |
||
| ) |
Add one index to the table, allowing to specify the desired order If it's not specified, then the index is added at the end
Detect duplicates first
Calculate the previous and next indexes
Set current index previous and next attributes
Some more attributes
Add the new index
Reorder the indexes
Recalculate the hash
We have one new index, so the table has changed
Definition at line 151 of file xmldb_table.php.


| addIndexInfo | ( | $ | name, |
| $ | type, | ||
| $ | fields | ||
| ) |
TODO: Delete for 2.1 (deprecated in 2.0). Deprecated API starts here
Definition at line 770 of file xmldb_table.php.

| addKey | ( | &$ | key, |
| $ | after = NULL |
||
| ) |
Add one key to the table, allowing to specify the desired order If it's not specified, then the key is added at the end
Detect duplicates first
Calculate the previous and next keys
Set current key previous and next attributes
Some more attributes
Add the new key
Reorder the keys
Recalculate the hash
We have one new field, so the table has changed
Definition at line 101 of file xmldb_table.php.


| addKeyInfo | ( | $ | name, |
| $ | type, | ||
| $ | fields, | ||
| $ | reftable = null, |
||
| $ | reffields = null |
||
| ) |
TODO: Delete for 2.1 (deprecated in 2.0). Deprecated API starts here
Definition at line 744 of file xmldb_table.php.

| arr2xmldb_table | ( | $ | xmlarr | ) |
Load data from XML to the table
Debug the table traverse_xmlize($xmlarr); //Debug print_object ($GLOBALS['traverse_array']); //Debug $GLOBALS['traverse_array']=""; //Debug
Process table attributes (name, comment, previoustable and nexttable)
Iterate over fields
Perform some general checks over fields
Check field names are ok (lowercase, a-z _-)
Check previous & next are ok (duplicates and existing fields)
Order fields
Iterate over keys
Perform some general checks over keys
Check keys names are ok (lowercase, a-z _-)
Check previous & next are ok (duplicates and existing keys)
Order keys
TODO: Only one PK TODO: Not keys with repeated fields TODO: Check fields and reffieds exist in table
Iterate over indexes
Perform some general checks over indexes
Check field names are ok (lowercase, a-z _-)
Check previous & next are ok (duplicates and existing INDEXES)
Order indexes
TODO: Not indexes with repeated fields TODO: Check fields exist in table
Set some attributes
Definition at line 444 of file xmldb_table.php.

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


| deleteField | ( | $ | fieldname | ) |
Delete one field from the table
Look for prev and next field
Change their previous and next attributes
Delete the field
Reorder the whole structure
Recalculate the hash
We have one deleted field, so the table has changed
Definition at line 357 of file xmldb_table.php.

| deleteIndex | ( | $ | indexname | ) |
Delete one index from the table
Look for prev and next index
Change their previous and next attributes
Delete the index
Reorder the indexes
Recalculate the hash
We have one deleted index, so the table has changed
Definition at line 415 of file xmldb_table.php.

| deleteKey | ( | $ | keyname | ) |
Delete one key from the table
Look for prev and next key
Change their previous and next attributes
Delete the key
Reorder the Keys
Recalculate the hash
We have one deleted key, so the table has changed
Definition at line 386 of file xmldb_table.php.

| & findFieldInArray | ( | $ | fieldname | ) |
Returns the position of one field in the array.
Definition at line 234 of file xmldb_table.php.

| & findIndexInArray | ( | $ | indexname | ) |
Returns the position of one index in the array.
Definition at line 310 of file xmldb_table.php.

| & findKeyInArray | ( | $ | keyname | ) |
Returns the position of one key in the array.
Definition at line 272 of file xmldb_table.php.

| getAllErrors | ( | ) |
This function will return all the errors found in one table looking recursively inside each field/key/index. Returns an array of errors or false
First the table itself
Delegate to fields
Delegate to keys
Delegate to indexes
Return decision
Definition at line 797 of file xmldb_table.php.

| & getField | ( | $ | fieldname | ) |
Returns one xmldb_field
Definition at line 222 of file xmldb_table.php.


| & getFields | ( | ) |
This function will return the array of fields in the table
Definition at line 201 of file xmldb_table.php.

| & getIndex | ( | $ | indexname | ) |
Returns one xmldb_index
Definition at line 298 of file xmldb_table.php.


| & getIndexes | ( | ) |
This function will return the array of indexes in the table
Definition at line 215 of file xmldb_table.php.

| & getKey | ( | $ | keyname | ) |
Returns one xmldb_key
Definition at line 260 of file xmldb_table.php.


| & getKeys | ( | ) |
This function will return the array of keys in the table
Definition at line 208 of file xmldb_table.php.

| orderFields | ( | ) |
This function will reorder the array of fields
Definition at line 247 of file xmldb_table.php.


| orderIndexes | ( | ) |
This function will reorder the array of indexes
Definition at line 323 of file xmldb_table.php.


| orderKeys | ( | ) |
This function will reorder the array of keys
Definition at line 285 of file xmldb_table.php.


| setFields | ( | $ | fields | ) |
This function will set the array of fields in the table
Definition at line 336 of file xmldb_table.php.

| setIndexes | ( | $ | indexes | ) |
This function will set the array of indexes in the table
Definition at line 350 of file xmldb_table.php.

| setKeys | ( | $ | keys | ) |
This function will set the array of keys in the table
Definition at line 343 of file xmldb_table.php.

| xmlOutput | ( | ) |
This function will output the XML text for one table
Now the fields
Now the keys
Now the indexes
Definition at line 665 of file xmldb_table.php.
| $fields |
Definition at line 31 of file xmldb_table.php.
| $indexes |
Definition at line 33 of file xmldb_table.php.
| $keys |
Definition at line 32 of file xmldb_table.php.