Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
xmldb_structure Class Reference
Inheritance diagram for xmldb_structure:
xmldb_object

Public Member Functions

 __construct ($name)
 Creates one new xmldb_structure.
 
 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.
 
 arr2xmldb_structure ($xmlarr)
 Load data from XML to the structure.
 
 calculateHash ($recursive=false)
 This function calculate and set the hash of one xmldb_structure.
 
 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.
 
 deleteTable ($tablename)
 Delete one table from the Structure.
 
 findObjectInArray ($objectname, $arr)
 Returns the position of one object in the array.
 
 findTableInArray ($tablename)
 Returns the position of one table in the array.
 
 fixPrevNext (&$arr)
 Reconstruct previous/next attributes.
 
 getAllErrors ()
 This function will return all the errors found in one structure looking recursively inside each table.
 
 getComment ()
 This function returns the comment of one xmldb_object.
 
 getError ()
 This function will return the error detected in the object.
 
 getFieldUses ($tablename, $fieldname)
 This function returns the number of uses of one field inside a whole xmldb_structure.
 
 getHash ()
 This function returns the hash of one xmldb_object.
 
 getIndexUses ($tablename, $indexname)
 This function returns the number of uses of one index inside a whole xmldb_structure.
 
 getKeyUses ($tablename, $keyname)
 This function returns the number of uses of one key inside a whole xmldb_structure.
 
 getName ()
 This function will return the name of the xmldb_object.
 
 getNext ()
 This function will return the name of the next xmldb_object.
 
 getPath ()
 Returns the path of the structure.
 
 getPrevious ()
 This function will return the name of the previous xmldb_object.
 
 getTable ($tablename)
 Returns one xmldb_table.
 
 getTables ()
 Returns the tables of the structure.
 
 getTableUses ($tablename)
 This function returns the number of uses of one table inside a whole XMLDStructure.
 
 getVersion ()
 Returns the version of the structure.
 
 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.
 
 orderTables ()
 This function will reorder the array of tables.
 
 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.
 
 setHash ($hash)
 This function will set the hash of the xmldb_object.
 
 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.
 
 setTables ($tables)
 Set the tables.
 
 setVersion ($version)
 Set the structure version.
 
 validateDefinition (xmldb_table $xmldb_table=null)
 Validates the definition of objects and returns error message.
 
 xmlOutput ()
 This function will output the XML text for one structure.
 

Protected Attributes

bool $changed
 was object changed
 
string $comment
 comment on object
 
string $errormsg
 error message
 
string $hash
 hash of object
 
bool $loaded
 is it loaded yet
 
string $name
 name of obejct
 
string $next
 
string $path
 
string $previous
 
xmldb_table[] $tables
 tables
 
string $version
 

Constructor & Destructor Documentation

◆ __construct()

xmldb_structure::__construct ( $name)

Creates one new xmldb_structure.

Parameters
string$name

Reimplemented from xmldb_object.

Member Function Documentation

◆ addTable()

xmldb_structure::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.

Parameters
xmldb_table$table
mixed$after

◆ arr2xmldb_structure()

xmldb_structure::arr2xmldb_structure ( $xmlarr)

Load data from XML to the structure.

Parameters
array$xmlarr
Return values
bool

◆ calculateHash()

xmldb_structure::calculateHash ( $recursive = false)

This function calculate and set the hash of one xmldb_structure.

Parameters
bool$recursive

◆ checkName()

xmldb_object::checkName ( )
inherited

This function will check if one key name is ok or no (true/false) only lowercase a-z, 0-9 and _ are allowed.

Return values
bool

◆ checkNameValues()

xmldb_object::checkNameValues ( $arr)
inherited

This function will check that all the elements in one array have a correct name [a-z0-9_].

Parameters
array$arr
Return values
bool

◆ comma2array()

xmldb_object::comma2array ( $string)
inherited

Returns one array of elements from one comma separated string, supporting quoted strings containing commas and concat function calls.

Parameters
string$string
Return values
array

◆ debug()

xmldb_object::debug ( $message)
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

Parameters
string$message

◆ deleteTable()

xmldb_structure::deleteTable ( $tablename)

Delete one table from the Structure.

Parameters
string$tablename

◆ findObjectInArray()

xmldb_object::findObjectInArray ( $objectname,
$arr )
inherited

Returns the position of one object in the array.

Parameters
string$objectname
array$arr
Return values
mixed

◆ findTableInArray()

xmldb_structure::findTableInArray ( $tablename)

Returns the position of one table in the array.

Parameters
string$tablename
Return values
mixed

◆ fixPrevNext()

xmldb_object::fixPrevNext ( & $arr)
inherited

Reconstruct previous/next attributes.

Parameters
array$arr
Return values
booltrue if $arr modified

◆ getAllErrors()

xmldb_structure::getAllErrors ( )

This function will return all the errors found in one structure looking recursively inside each table.

Returns an array of errors or false

Return values
mixed

◆ getComment()

xmldb_object::getComment ( )
inherited

This function returns the comment of one xmldb_object.

Return values
string

◆ getError()

xmldb_object::getError ( )
inherited

This function will return the error detected in the object.

Return values
string

◆ getFieldUses()

xmldb_structure::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.

Parameters
string$tablename
string$fieldname
Return values
mixed

◆ getHash()

xmldb_object::getHash ( )
inherited

This function returns the hash of one xmldb_object.

Return values
string

◆ getIndexUses()

xmldb_structure::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.

Parameters
string$tablename
string$indexname
Return values
mixed

◆ getKeyUses()

xmldb_structure::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.

Parameters
string$tablename
string$keyname
Return values
mixed

◆ getName()

xmldb_object::getName ( )
inherited

This function will return the name of the xmldb_object.

Return values
string

◆ getNext()

xmldb_object::getNext ( )
inherited

This function will return the name of the next xmldb_object.

Return values
string

◆ getPath()

xmldb_structure::getPath ( )

Returns the path of the structure.

Return values
string

◆ getPrevious()

xmldb_object::getPrevious ( )
inherited

This function will return the name of the previous xmldb_object.

Return values
string

◆ getTable()

xmldb_structure::getTable ( $tablename)

Returns one xmldb_table.

Parameters
string$tablename
Return values
xmldb_table

◆ getTables()

xmldb_structure::getTables ( )

Returns the tables of the structure.

Return values
array

◆ getTableUses()

xmldb_structure::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.

Parameters
string$tablename
Return values
mixed

◆ getVersion()

xmldb_structure::getVersion ( )

Returns the version of the structure.

Return values
string

◆ hasChanged()

xmldb_object::hasChanged ( )
inherited

This function returns true/false, if the xmldb_object has changed.

Return values
bool

◆ isLoaded()

xmldb_object::isLoaded ( )
inherited

This function returns true/false, if the xmldb_object has been loaded.

Return values
bool

◆ orderElements()

xmldb_object::orderElements ( $arr)
inherited

This function will order all the elements in one array, following the previous/next rules.

Parameters
array$arr
Return values
array|bool

◆ orderTables()

xmldb_structure::orderTables ( )

This function will reorder the array of tables.

Return values
boolsuccess

◆ readableInfo()

xmldb_object::readableInfo ( )
inherited

This function will display a readable info about the xmldb_object (should be implemented inside each XMLDBxxx object)

Return values
string

Reimplemented in xmldb_field, xmldb_index, and xmldb_key.

◆ setChanged()

xmldb_object::setChanged ( $changed = true)
inherited

This function will set the changed field of the xmldb_object.

Parameters
bool$changed

◆ setComment()

xmldb_object::setComment ( $comment)
inherited

This function will set the comment of the xmldb_object.

Parameters
string$comment

◆ setHash()

xmldb_object::setHash ( $hash)
inherited

This function will set the hash of the xmldb_object.

Parameters
string$hash

◆ setLoaded()

xmldb_object::setLoaded ( $loaded = true)
inherited

This function will set the loaded field of the xmldb_object.

Parameters
bool$loaded

◆ setName()

xmldb_object::setName ( $name)
inherited

This function will set the name field of the xmldb_object.

Parameters
string$name

◆ setNext()

xmldb_object::setNext ( $next)
inherited

This function will set the next of the xmldb_object.

Parameters
string$next

◆ setPrevious()

xmldb_object::setPrevious ( $previous)
inherited

This function will set the previous of the xmldb_object.

Parameters
string$previous

◆ setTables()

xmldb_structure::setTables ( $tables)

Set the tables.

Parameters
array$tables

◆ setVersion()

xmldb_structure::setVersion ( $version)

Set the structure version.

Parameters
stringversion

◆ validateDefinition()

xmldb_object::validateDefinition ( xmldb_table $xmldb_table = null)
inherited

Validates the definition of objects and returns error message.

The error message should not be localised because it is intended for developers, end users and admins should never see these problems!

Parameters
xmldb_table$xmldb_tableoptional when object is table
Return values
stringnull if ok, error message if problem found

Reimplemented in xmldb_field, xmldb_index, and xmldb_table.

◆ xmlOutput()

xmldb_structure::xmlOutput ( )

This function will output the XML text for one structure.

Return values
string

The documentation for this class was generated from the following file: