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] [Versions 401 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