Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
|
Public Member Functions | |
__construct ($name) | |
Creates one new 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. | |
add_index ($name, $type, $fields, $hints=array()) | |
This function will add one new index to the table with all its attributes defined. | |
add_key ($name, $type, $fields, $reftable=null, $reffields=null) | |
This function will add one new key to the table with all its attributes defined. | |
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. | |
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. | |
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. | |
arr2xmldb_table ($xmlarr) | |
Load data from XML to the table. | |
calculateHash ($recursive=false) | |
This function calculate and set the hash of one xmldb_table. | |
checkName () | |
This function will check if one key name is ok or no (true/false) only lowercase a-z, 0-9 and _ are allowed. | |
checkNameValues ($arr) | |
This function will check that all the elements in one array have a correct name [a-z0-9_]. | |
comma2array ($string) | |
Returns one array of elements from one comma separated string, supporting quoted strings containing commas and concat function calls. | |
debug ($message) | |
This function will perform the central debug of all the XMLDB classes being called automatically every time one error is found. | |
deleteField ($fieldname) | |
Delete one field from the table. | |
deleteIndex ($indexname) | |
Delete one index from the table. | |
deleteKey ($keyname) | |
Delete one key from the table. | |
findFieldInArray ($fieldname) | |
Returns the position of one field in the array. | |
findIndexInArray ($indexname) | |
Returns the position of one index in the array. | |
findKeyInArray ($keyname) | |
Returns the position of one key in the array. | |
findObjectInArray ($objectname, $arr) | |
Returns the position of one object in the array. | |
fixPrevNext (&$arr) | |
Reconstruct previous/next attributes. | |
getAllErrors () | |
This function will return all the errors found in one table looking recursively inside each field/key/index. | |
getComment () | |
This function returns the comment of one xmldb_object. | |
getError () | |
This function will return the error detected in the object. | |
getField ($fieldname) | |
Returns one xmldb_field. | |
getFields () | |
This function will return the array of fields in the table. | |
getHash () | |
This function returns the hash of one xmldb_object. | |
getIndex ($indexname) | |
Returns one xmldb_index. | |
getIndexes () | |
This function will return the array of indexes in the table. | |
getKey ($keyname) | |
Returns one xmldb_key. | |
getKeys () | |
This function will return the array of keys in the table. | |
getName () | |
This function will return the name of the xmldb_object. | |
getNext () | |
This function will return the name of the next xmldb_object. | |
getPrevious () | |
This function will return the name of the previous xmldb_object. | |
hasChanged () | |
This function returns true/false, if the xmldb_object has changed. | |
isLoaded () | |
This function returns true/false, if the xmldb_object has been loaded. | |
orderElements ($arr) | |
This function will order all the elements in one array, following the previous/next rules. | |
orderFields () | |
This function will reorder the array of fields. | |
orderIndexes () | |
This function will reorder the array of indexes. | |
orderKeys () | |
This function will reorder the array of keys. | |
readableInfo () | |
This function will display a readable info about the xmldb_object (should be implemented inside each XMLDBxxx object) | |
setChanged ($changed=true) | |
This function will set the changed field of the xmldb_object. | |
setComment ($comment) | |
This function will set the comment of the xmldb_object. | |
setFields ($fields) | |
This function will set the array of fields in the table. | |
setHash ($hash) | |
This function will set the hash of the xmldb_object. | |
setIndexes ($indexes) | |
This function will set the array of indexes in the table. | |
setKeys ($keys) | |
This function will set the array of keys in the table. | |
setLoaded ($loaded=true) | |
This function will set the loaded field of the xmldb_object. | |
setName ($name) | |
This function will set the name field of the xmldb_object. | |
setNext ($next) | |
This function will set the next of the xmldb_object. | |
setPrevious ($previous) | |
This function will set the previous of the xmldb_object. | |
validateDefinition (xmldb_table $xmldb_table=null) | |
Validates the table restrictions (does not validate child elements). | |
xmlOutput () | |
This function will output the XML text for one table. | |
Public Attributes | |
int const | NAME_MAX_LENGTH = 63 - self::PREFIX_MAX_LENGTH |
Note: | |
int const | PREFIX_MAX_LENGTH = 10 |
max length of table name prefixes | |
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 | |
string | $next |
string | $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.
string |
|
inherited |
This function will return the name of the previous xmldb_object.
string |
|
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.
string | $next |
|
inherited |
This function will set the previous of the xmldb_object.
string | $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 |
int const xmldb_table::NAME_MAX_LENGTH = 63 - self::PREFIX_MAX_LENGTH |
Note:
max length of table names (without prefix).