Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

This class represent one XMLDB Index

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

Defines 1 class

xmldb_index:: (15 methods):
  __construct()
  set_attributes()
  getUnique()
  setUnique()
  setFields()
  getFields()
  setHints()
  getHints()
  arr2xmldb_index()
  calculateHash()
  xmlOutput()
  setFromADOIndex()
  getPHP()
  readableInfo()
  validateDefinition()


Class: xmldb_index  - X-Ref

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

param: string $name
param: string $type XMLDB_INDEX_UNIQUE, XMLDB_INDEX_NOTUNIQUE
param: array $fields an array of fieldnames to build the index over
param: array $hints an array of optional hints

set_attributes($type, $fields, $hints = array()   X-Ref
Set all the attributes of one xmldb_index

param: string type XMLDB_INDEX_UNIQUE, XMLDB_INDEX_NOTUNIQUE
param: array fields an array of fieldnames to build the index over
param: array $hints array of optional hints

getUnique()   X-Ref
Get the index unique

return: bool

setUnique($unique = true)   X-Ref
Set the index unique

param: bool $unique

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

param: array $fields

getFields()   X-Ref
Get the index fields

return: array

setHints($hints)   X-Ref
Set optional index hints.

param: array $hints

getHints()   X-Ref
Returns optional index hints.

return: array

arr2xmldb_index($xmlarr)   X-Ref
Load data from XML to the index

param: $xmlarr array
return: bool

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


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

return: string

setFromADOIndex($adoindex)   X-Ref
This function will set all the attributes of the xmldb_index object
based on information passed in one ADOindex

param: array
return: void

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

return: string

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

return: string

validateDefinition(xmldb_table $xmldb_table=null)   X-Ref
Validates the index restrictions.

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

param: xmldb_table $xmldb_table optional when object is table
return: string null if ok, error message if problem found