Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

This class represent one XMLDB structure

Copyright: 1999 onwards Martin Dougiamas http://dougiamas.com
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 558 lines (18 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

xmldb_structure:: (19 methods):
  __construct()
  getPath()
  getVersion()
  getTable()
  findTableInArray()
  orderTables()
  getTables()
  setVersion()
  addTable()
  deleteTable()
  setTables()
  arr2xmldb_structure()
  calculateHash()
  xmlOutput()
  getTableUses()
  getFieldUses()
  getKeyUses()
  getIndexUses()
  getAllErrors()


Class: xmldb_structure  - X-Ref

__construct($name)   X-Ref
Creates one new xmldb_structure

param: string $name

getPath()   X-Ref
Returns the path of the structure

return: string

getVersion()   X-Ref
Returns the version of the structure

return: string

getTable($tablename)   X-Ref
Returns one xmldb_table

param: string $tablename
return: xmldb_table

findTableInArray($tablename)   X-Ref
Returns the position of one table in the array.

param: string $tablename
return: mixed

orderTables()   X-Ref
This function will reorder the array of tables

return: bool success

getTables()   X-Ref
Returns the tables of the structure

return: array

setVersion($version)   X-Ref
Set the structure version

param: string version

addTable($table, $after=null)   X-Ref
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.

param: xmldb_table $table
param: mixed $after

deleteTable($tablename)   X-Ref
Delete one table from the Structure

param: string $tablename

setTables($tables)   X-Ref
Set the tables

param: array $tables

arr2xmldb_structure($xmlarr)   X-Ref
Load data from XML to the structure

param: array $xmlarr
return: bool

calculateHash($recursive = false)   X-Ref
This function calculate and set the hash of one xmldb_structure

param: bool $recursive

xmlOutput()   X-Ref
This function will output the XML text for one structure

return: string

getTableUses($tablename)   X-Ref
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.

param: string $tablename
return: mixed

getFieldUses($tablename, $fieldname)   X-Ref
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.

param: string $tablename
param: string $fieldname
return: mixed

getKeyUses($tablename, $keyname)   X-Ref
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.

param: string $tablename
param: string $keyname
return: mixed

getIndexUses($tablename, $indexname)   X-Ref
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.

param: string $tablename
param: string $indexname
return: mixed

getAllErrors()   X-Ref
This function will return all the errors found in one structure
looking recursively inside each table. Returns
an array of errors or false

return: mixed