Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

This class represent one XMLDB Key

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

Defines 1 class

xmldb_key:: (18 methods):
  __construct()
  set_attributes()
  getType()
  setType()
  setFields()
  setRefTable()
  setRefFields()
  getFields()
  getRefTable()
  getRefFields()
  arr2xmldb_key()
  getXMLDBKeyType()
  getXMLDBKeyName()
  calculateHash()
  xmlOutput()
  setFromADOKey()
  getPHP()
  readableInfo()


Class: xmldb_key  - X-Ref

__construct($name, $type=null, $fields=array()   X-Ref
Creates one new xmldb_key

param: string $name
param: string $type XMLDB_KEY_[PRIMARY|UNIQUE|FOREIGN|FOREIGN_UNIQUE]
param: array $fields an array of fieldnames to build the key over
param: string $reftable name of the table the FK points to or null
param: array $reffields an array of fieldnames in the FK table or null

set_attributes($type, $fields, $reftable=null, $reffields=null)   X-Ref
Set all the attributes of one xmldb_key

param: string $type XMLDB_KEY_[PRIMARY|UNIQUE|FOREIGN|FOREIGN_UNIQUE]
param: array $fields an array of fieldnames to build the key over
param: string $reftable name of the table the FK points to or null
param: array $reffields an array of fieldnames in the FK table or null

getType()   X-Ref
Get the key type

return: int

setType($type)   X-Ref
Set the key type

param: int $type

setFields($fields)   X-Ref
Set the key fields

param: array $fields

setRefTable($reftable)   X-Ref
Set the key reftable

param: string $reftable

setRefFields($reffields)   X-Ref
Set the key reffields

param: array $reffields

getFields()   X-Ref
Get the key fields

return: array

getRefTable()   X-Ref
Get the key reftable

return: string

getRefFields()   X-Ref
Get the key reffields

return: array reference to ref fields

arr2xmldb_key($xmlarr)   X-Ref
Load data from XML to the key

param: array $xmlarr
return: bool success

getXMLDBKeyType($type)   X-Ref
This function returns the correct XMLDB_KEY_XXX value for the
string passed as argument

param: string $type
return: int

getXMLDBKeyName($type)   X-Ref
This function returns the correct name value for the
XMLDB_KEY_XXX passed as argument

param: int $type
return: string

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

param: bool $recursive

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

return: string

setFromADOKey($adokey)   X-Ref
This function will set all the attributes of the xmldb_key object
based on information passed in one ADOkey


getPHP()   X-Ref
Returns the PHP code needed to define one xmldb_key

return: string

readableInfo()   X-Ref
Shows info in a readable format

return: string