Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

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

This class represent the XMLDB base class where all the common pieces are defined

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

Defines 1 class

xmldb_object:: (25 methods):
  __construct()
  isLoaded()
  hasChanged()
  getComment()
  getHash()
  getPrevious()
  getNext()
  getName()
  getError()
  setComment()
  setPrevious()
  setNext()
  setHash()
  setLoaded()
  setChanged()
  setName()
  checkName()
  checkNameValues()
  fixPrevNext()
  orderElements()
  findObjectInArray()
  readableInfo()
  debug()
  comma2array()
  validateDefinition()


Class: xmldb_object  - X-Ref

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

param: string $name

isLoaded()   X-Ref
This function returns true/false, if the xmldb_object has been loaded

return: bool

hasChanged()   X-Ref
This function returns true/false, if the xmldb_object has changed

return: bool

getComment()   X-Ref
This function returns the comment of one xmldb_object

return: string

getHash()   X-Ref
This function returns the hash of one xmldb_object

return: string

getPrevious()   X-Ref
This function will return the name of the previous xmldb_object

return: string

getNext()   X-Ref
This function will return the name of the next xmldb_object

return: string

getName()   X-Ref
This function will return the name of the xmldb_object

return: string

getError()   X-Ref
This function will return the error detected in the object

return: string

setComment($comment)   X-Ref
This function will set the comment of the xmldb_object

param: string $comment

setPrevious($previous)   X-Ref
This function will set the previous of the xmldb_object

param: string $previous

setNext($next)   X-Ref
This function will set the next of the xmldb_object

param: string $next

setHash($hash)   X-Ref
This function will set the hash of the xmldb_object

param: string $hash

setLoaded($loaded = true)   X-Ref
This function will set the loaded field of the xmldb_object

param: bool $loaded

setChanged($changed = true)   X-Ref
This function will set the changed field of the xmldb_object

param: bool $changed

setName($name)   X-Ref
This function will set the name field of the xmldb_object

param: string $name

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

return: bool

checkNameValues($arr)   X-Ref
This function will check that all the elements in one array
have a correct name [a-z0-9_]

param: array $arr
return: bool

fixPrevNext(&$arr)   X-Ref
Reconstruct previous/next attributes.

param: array $arr
return: bool true if $arr modified

orderElements($arr)   X-Ref
This function will order all the elements in one array, following
the previous/next rules

param: array $arr
return: array|bool

findObjectInArray($objectname, $arr)   X-Ref
Returns the position of one object in the array.

param: string $objectname
param: array $arr
return: mixed

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

return: string

debug($message)   X-Ref
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
param: string $message

comma2array($string)   X-Ref
Returns one array of elements from one comma separated string,
supporting quoted strings containing commas and concat function calls

param: string $string
return: array

validateDefinition(xmldb_table $xmldb_table=null)   X-Ref
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!

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