Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Public Member Functions | |
__construct ($name) | |
Creates one new xmldb_table. More... | |
add_field ($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) | |
This function will add one new field to the table with all its attributes defined. More... | |
add_index ($name, $type, $fields, $hints=array()) | |
This function will add one new index to the table with all its attributes defined. More... | |
add_key ($name, $type, $fields, $reftable=null, $reffields=null) | |
This function will add one new key to the table with all its attributes defined. More... | |
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. More... | |
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. More... | |
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. More... | |
arr2xmldb_table ($xmlarr) | |
Load data from XML to the table. More... | |
calculateHash ($recursive=false) | |
This function calculate and set the hash of one xmldb_table. More... | |
checkName () | |
This function will check if one key name is ok or no (true/false) only lowercase a-z, 0-9 and _ are allowed. More... | |
checkNameValues ($arr) | |
This function will check that all the elements in one array have a correct name [a-z0-9_]. More... | |
comma2array ($string) | |
Returns one array of elements from one comma separated string, supporting quoted strings containing commas and concat function calls. More... | |
debug ($message) | |
This function will perform the central debug of all the XMLDB classes being called automatically every time one error is found. More... | |
deleteField ($fieldname) | |
Delete one field from the table. More... | |
deleteIndex ($indexname) | |
Delete one index from the table. More... | |
deleteKey ($keyname) | |
Delete one key from the table. More... | |
findFieldInArray ($fieldname) | |
Returns the position of one field in the array. More... | |
findIndexInArray ($indexname) | |
Returns the position of one index in the array. More... | |
findKeyInArray ($keyname) | |
Returns the position of one key in the array. More... | |
findObjectInArray ($objectname, $arr) | |
Returns the position of one object in the array. More... | |
fixPrevNext (&$arr) | |
Reconstruct previous/next attributes. More... | |
getAllErrors () | |
This function will return all the errors found in one table looking recursively inside each field/key/index. More... | |
getComment () | |
This function returns the comment of one xmldb_object. More... | |
getError () | |
This function will return the error detected in the object. More... | |
getField ($fieldname) | |
Returns one xmldb_field. More... | |
getFields () | |
This function will return the array of fields in the table. More... | |
getHash () | |
This function returns the hash of one xmldb_object. More... | |
getIndex ($indexname) | |
Returns one xmldb_index. More... | |
getIndexes () | |
This function will return the array of indexes in the table. More... | |
getKey ($keyname) | |
Returns one xmldb_key. More... | |
getKeys () | |
This function will return the array of keys in the table. More... | |
getName () | |
This function will return the name of the xmldb_object. More... | |
getNext () | |
This function will return the name of the next xmldb_object. More... | |
getPrevious () | |
This function will return the name of the previous xmldb_object. More... | |
hasChanged () | |
This function returns true/false, if the xmldb_object has changed. More... | |
isLoaded () | |
This function returns true/false, if the xmldb_object has been loaded. More... | |
orderElements ($arr) | |
This function will order all the elements in one array, following the previous/next rules. More... | |
orderFields () | |
This function will reorder the array of fields. More... | |
orderIndexes () | |
This function will reorder the array of indexes. More... | |
orderKeys () | |
This function will reorder the array of keys. More... | |
readableInfo () | |
This function will display a readable info about the xmldb_object (should be implemented inside each XMLDBxxx object) More... | |
setChanged ($changed=true) | |
This function will set the changed field of the xmldb_object. More... | |
setComment ($comment) | |
This function will set the comment of the xmldb_object. More... | |
setFields ($fields) | |
This function will set the array of fields in the table. More... | |
setHash ($hash) | |
This function will set the hash of the xmldb_object. More... | |
setIndexes ($indexes) | |
This function will set the array of indexes in the table. More... | |
setKeys ($keys) | |
This function will set the array of keys in the table. More... | |
setLoaded ($loaded=true) | |
This function will set the loaded field of the xmldb_object. More... | |
setName ($name) | |
This function will set the name field of the xmldb_object. More... | |
setNext ($next) | |
This function will set the next of the xmldb_object. More... | |
setPrevious ($previous) | |
This function will set the previous of the xmldb_object. More... | |
validateDefinition (xmldb_table $xmldb_table=null) | |
Validates the table restrictions (does not validate child elements). More... | |
xmlOutput () | |
This function will output the XML text for one table. More... | |
Public Attributes | |
const | NAME_MAX_LENGTH = 28 |
Note: More... | |
Protected Attributes | |
bool | $changed |
was object changed | |
string | $comment |
comment on object | |
string | $errormsg |
error message | |
xmldb_field[] | $fields |
table columns | |
string | $hash |
hash of object | |
xmldb_index[] | $indexes |
indexes | |
xmldb_key[] | $keys |
keys | |
bool | $loaded |
is it loaded yet | |
string | $name |
name of obejct | |
xmldb_object | $next |
xmldb_object | $previous |
xmldb_table::__construct | ( | $name | ) |
xmldb_table::add_field | ( | $name, | |
$type, | |||
$precision = null , |
|||
$unsigned = null , |
|||
$notnull = null , |
|||
$sequence = null , |
|||
$default = null , |
|||
$previous = null |
|||
) |
This function will add one new field to the table with all its attributes defined.
string | $name | name of the field |
int | $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 |
bool | $unsigned | XMLDB_UNSIGNED or null (or false) |
bool | $notnull | XMLDB_NOTNULL or null (or false) |
bool | $sequence | XMLDB_SEQUENCE or null (or false) |
mixed | $default | meaningful default o null (or false) |
xmldb_object | $previous | name of the previous field in the table or null (or false) |
xmlddb_field |
xmldb_table::add_index | ( | $name, | |
$type, | |||
$fields, | |||
$hints = array() |
|||
) |
This function will add one new index to the table with all its attributes defined.
string | $name | name of the index |
int | $type | XMLDB_INDEX_UNIQUE, XMLDB_INDEX_NOTUNIQUE |
array | $fields | an array of fieldnames to build the index over |
array | $hints | optional index type hints |
xmldb_table::add_key | ( | $name, | |
$type, | |||
$fields, | |||
$reftable = null , |
|||
$reffields = null |
|||
) |
This function will add one new key to the table with all its attributes defined.
string | $name | name of the key |
int | $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 |
xmldb_table::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.
xmldb_field | $field | |
xmldb_object | $after |
xmldb_field |
xmldb_table::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.
xmldb_index | $index | |
xmldb_object | $after |
xmldb_table::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.
xmldb_key | $key | |
xmldb_object | $after |
xmldb_table::arr2xmldb_table | ( | $xmlarr | ) |
Load data from XML to the table.
array | $xmlarr |
bool | success |
xmldb_table::calculateHash | ( | $recursive = false | ) |
This function calculate and set the hash of one xmldb_table.
bool | $recursive |
|
inherited |
This function will check if one key name is ok or no (true/false) only lowercase a-z, 0-9 and _ are allowed.
bool |
|
inherited |
This function will check that all the elements in one array have a correct name [a-z0-9_].
array | $arr |
bool |
|
inherited |
Returns one array of elements from one comma separated string, supporting quoted strings containing commas and concat function calls.
string | $string |
array |
|
inherited |
This function will perform the central debug of all the XMLDB classes being called automatically every time one error is found.
Apart from the main actions performed in it (XMLDB agnostic) it looks for one function called xmldb_debug() and invokes it, passing both the message code and the whole object. So, to perform custom debugging just add such function to your libs.
Call to the external hook function can be disabled by request by defining XMLDB_SKIP_DEBUG_HOOK
string | $message |
xmldb_table::deleteField | ( | $fieldname | ) |
Delete one field from the table.
string | $fieldname |
xmldb_table::deleteIndex | ( | $indexname | ) |
Delete one index from the table.
string | $indexname |
xmldb_table::deleteKey | ( | $keyname | ) |
Delete one key from the table.
string | $keyname |
xmldb_table::findFieldInArray | ( | $fieldname | ) |
Returns the position of one field in the array.
string | $fieldname |
int|null | index of the field, or null if not found. |
xmldb_table::findIndexInArray | ( | $indexname | ) |
Returns the position of one index in the array.
string | $indexname |
int|null | index of the index, or null if not found. |
xmldb_table::findKeyInArray | ( | $keyname | ) |
Returns the position of one key in the array.
string | $keyname |
int|null | index of the key, or null if not found. |
|
inherited |
Returns the position of one object in the array.
string | $objectname | |
array | $arr |
mixed |
|
inherited |
Reconstruct previous/next attributes.
array | $arr |
bool | true if $arr modified |
xmldb_table::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
|
inherited |
This function returns the comment of one xmldb_object.
string |
|
inherited |
This function will return the error detected in the object.
string |
xmldb_table::getField | ( | $fieldname | ) |
xmldb_table::getFields | ( | ) |
This function will return the array of fields in the table.
xmldb_field[] |
|
inherited |
This function returns the hash of one xmldb_object.
string |
xmldb_table::getIndex | ( | $indexname | ) |
xmldb_table::getIndexes | ( | ) |
This function will return the array of indexes in the table.
xmldb_index[] |
xmldb_table::getKey | ( | $keyname | ) |
xmldb_table::getKeys | ( | ) |
This function will return the array of keys in the table.
xmldb_key[] |
|
inherited |
This function will return the name of the xmldb_object.
string |
|
inherited |
This function will return the name of the next xmldb_object.
xmldb_object |
|
inherited |
This function will return the name of the previous xmldb_object.
xmldb_object |
|
inherited |
This function returns true/false, if the xmldb_object has changed.
bool |
|
inherited |
This function returns true/false, if the xmldb_object has been loaded.
bool |
|
inherited |
This function will order all the elements in one array, following the previous/next rules.
array | $arr |
array|bool |
xmldb_table::orderFields | ( | ) |
This function will reorder the array of fields.
bool | whether the reordering succeeded. |
xmldb_table::orderIndexes | ( | ) |
This function will reorder the array of indexes.
bool | whether the reordering succeeded. |
xmldb_table::orderKeys | ( | ) |
This function will reorder the array of keys.
bool | whether the reordering succeeded. |
|
inherited |
This function will display a readable info about the xmldb_object (should be implemented inside each XMLDBxxx object)
string |
Reimplemented in xmldb_field, xmldb_index, and xmldb_key.
|
inherited |
This function will set the changed field of the xmldb_object.
bool | $changed |
|
inherited |
This function will set the comment of the xmldb_object.
string | $comment |
xmldb_table::setFields | ( | $fields | ) |
This function will set the array of fields in the table.
xmldb_field[] | $fields |
|
inherited |
This function will set the hash of the xmldb_object.
string | $hash |
xmldb_table::setIndexes | ( | $indexes | ) |
This function will set the array of indexes in the table.
xmldb_index[] | $indexes |
xmldb_table::setKeys | ( | $keys | ) |
This function will set the array of keys in the table.
xmldb_key[] | $keys |
|
inherited |
This function will set the loaded field of the xmldb_object.
bool | $loaded |
|
inherited |
This function will set the name field of the xmldb_object.
string | $name |
|
inherited |
This function will set the next of the xmldb_object.
xmldb_object | $next |
|
inherited |
This function will set the previous of the xmldb_object.
xmldb_object | $previous |
xmldb_table::validateDefinition | ( | xmldb_table | $xmldb_table = null | ) |
Validates the table restrictions (does not validate child elements).
The error message should not be localised because it is intended for developers, end users and admins should never see these problems!
xmldb_table | $xmldb_table | optional when object is table |
string | null if ok, error message if problem found |
Reimplemented from xmldb_object.
xmldb_table::xmlOutput | ( | ) |
This function will output the XML text for one table.
string |
const xmldb_table::NAME_MAX_LENGTH = 28 |
Note:
@const maximum length of field names