Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
xmldb_key Class Reference
Inheritance diagram for xmldb_key:
xmldb_object

Public Member Functions

 __construct ($name, $type=null, $fields=array(), $reftable=null, $reffields=null)
 Creates one new xmldb_key.
 
 arr2xmldb_key ($xmlarr)
 Load data from XML to the key.
 
 calculateHash ($recursive=false)
 This function calculate and set the hash of one xmldb_key.
 
 checkName ()
 This function will check if one key name is ok or no (true/false) only lowercase a-z, 0-9 and _ are allowed.
 
 checkNameValues ($arr)
 This function will check that all the elements in one array have a correct name [a-z0-9_].
 
 comma2array ($string)
 Returns one array of elements from one comma separated string, supporting quoted strings containing commas and concat function calls.
 
 debug ($message)
 This function will perform the central debug of all the XMLDB classes being called automatically every time one error is found.
 
 findObjectInArray ($objectname, $arr)
 Returns the position of one object in the array.
 
 fixPrevNext (&$arr)
 Reconstruct previous/next attributes.
 
 getComment ()
 This function returns the comment of one xmldb_object.
 
 getError ()
 This function will return the error detected in the object.
 
 getFields ()
 Get the key fields.
 
 getHash ()
 This function returns the hash of one xmldb_object.
 
 getName ()
 This function will return the name of the xmldb_object.
 
 getNext ()
 This function will return the name of the next xmldb_object.
 
 getPHP ()
 Returns the PHP code needed to define one xmldb_key.
 
 getPrevious ()
 This function will return the name of the previous xmldb_object.
 
 getRefFields ()
 Get the key reffields.
 
 getRefTable ()
 Get the key reftable.
 
 getType ()
 Get the key type.
 
 getXMLDBKeyName ($type)
 This function returns the correct name value for the XMLDB_KEY_XXX passed as argument.
 
 getXMLDBKeyType ($type)
 This function returns the correct XMLDB_KEY_XXX value for the string passed as argument.
 
 hasChanged ()
 This function returns true/false, if the xmldb_object has changed.
 
 isLoaded ()
 This function returns true/false, if the xmldb_object has been loaded.
 
 orderElements ($arr)
 This function will order all the elements in one array, following the previous/next rules.
 
 readableInfo ()
 Shows info in a readable format.
 
 set_attributes ($type, $fields, $reftable=null, $reffields=null)
 Set all the attributes of one xmldb_key.
 
 setChanged ($changed=true)
 This function will set the changed field of the xmldb_object.
 
 setComment ($comment)
 This function will set the comment of the xmldb_object.
 
 setFields ($fields)
 Set the key fields.
 
 setFromADOKey ($adokey)
 This function will set all the attributes of the xmldb_key object based on information passed in one ADOkey @oaram array $adokey.
 
 setHash ($hash)
 This function will set the hash of the xmldb_object.
 
 setLoaded ($loaded=true)
 This function will set the loaded field of the xmldb_object.
 
 setName ($name)
 This function will set the name field of the xmldb_object.
 
 setNext ($next)
 This function will set the next of the xmldb_object.
 
 setPrevious ($previous)
 This function will set the previous of the xmldb_object.
 
 setRefFields ($reffields)
 Set the key reffields.
 
 setRefTable ($reftable)
 Set the key reftable.
 
 setType ($type)
 Set the key type.
 
 validateDefinition (xmldb_table $xmldb_table=null)
 Validates the definition of objects and returns error message.
 
 xmlOutput ()
 This function will output the XML text for one key.
 

Protected Attributes

bool $changed
 was object changed
 
string $comment
 comment on object
 
string $errormsg
 error message
 
array $fields
 of fields
 
string $hash
 hash of object
 
bool $loaded
 is it loaded yet
 
string $name
 name of obejct
 
string $next
 
string $previous
 
array $reffields
 referenced fields
 
string $reftable
 referenced table
 
int $type
 type of key
 

Constructor & Destructor Documentation

◆ __construct()

xmldb_key::__construct ( $name,
$type = null,
$fields = array(),
$reftable = null,
$reffields = null )

Creates one new xmldb_key.

Parameters
string$name
string$typeXMLDB_KEY_[PRIMARY|UNIQUE|FOREIGN|FOREIGN_UNIQUE]
array$fieldsan array of fieldnames to build the key over
string$reftablename of the table the FK points to or null
array$reffieldsan array of fieldnames in the FK table or null

Member Function Documentation

◆ arr2xmldb_key()

xmldb_key::arr2xmldb_key ( $xmlarr)

Load data from XML to the key.

Parameters
array$xmlarr
Return values
boolsuccess

◆ calculateHash()

xmldb_key::calculateHash ( $recursive = false)

This function calculate and set the hash of one xmldb_key.

Parameters
bool$recursive

◆ checkName()

xmldb_object::checkName ( )
inherited

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

Return values
bool

◆ checkNameValues()

xmldb_object::checkNameValues ( $arr)
inherited

This function will check that all the elements in one array have a correct name [a-z0-9_].

Parameters
array$arr
Return values
bool

◆ comma2array()

xmldb_object::comma2array ( $string)
inherited

Returns one array of elements from one comma separated string, supporting quoted strings containing commas and concat function calls.

Parameters
string$string
Return values
array

◆ debug()

xmldb_object::debug ( $message)
inherited

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

Parameters
string$message

◆ findObjectInArray()

xmldb_object::findObjectInArray ( $objectname,
$arr )
inherited

Returns the position of one object in the array.

Parameters
string$objectname
array$arr
Return values
mixed

◆ fixPrevNext()

xmldb_object::fixPrevNext ( & $arr)
inherited

Reconstruct previous/next attributes.

Parameters
array$arr
Return values
booltrue if $arr modified

◆ getComment()

xmldb_object::getComment ( )
inherited

This function returns the comment of one xmldb_object.

Return values
string

◆ getError()

xmldb_object::getError ( )
inherited

This function will return the error detected in the object.

Return values
string

◆ getFields()

xmldb_key::getFields ( )

Get the key fields.

Return values
array

◆ getHash()

xmldb_object::getHash ( )
inherited

This function returns the hash of one xmldb_object.

Return values
string

◆ getName()

xmldb_object::getName ( )
inherited

This function will return the name of the xmldb_object.

Return values
string

◆ getNext()

xmldb_object::getNext ( )
inherited

This function will return the name of the next xmldb_object.

Return values
string

◆ getPHP()

xmldb_key::getPHP ( )

Returns the PHP code needed to define one xmldb_key.

Return values
string

◆ getPrevious()

xmldb_object::getPrevious ( )
inherited

This function will return the name of the previous xmldb_object.

Return values
string

◆ getRefFields()

xmldb_key::getRefFields ( )

Get the key reffields.

Return values
arrayreference to ref fields

◆ getRefTable()

xmldb_key::getRefTable ( )

Get the key reftable.

Return values
string

◆ getType()

xmldb_key::getType ( )

Get the key type.

Return values
int

◆ getXMLDBKeyName()

xmldb_key::getXMLDBKeyName ( $type)

This function returns the correct name value for the XMLDB_KEY_XXX passed as argument.

Parameters
int$type
Return values
string

◆ getXMLDBKeyType()

xmldb_key::getXMLDBKeyType ( $type)

This function returns the correct XMLDB_KEY_XXX value for the string passed as argument.

Parameters
string$type
Return values
int

◆ hasChanged()

xmldb_object::hasChanged ( )
inherited

This function returns true/false, if the xmldb_object has changed.

Return values
bool

◆ isLoaded()

xmldb_object::isLoaded ( )
inherited

This function returns true/false, if the xmldb_object has been loaded.

Return values
bool

◆ orderElements()

xmldb_object::orderElements ( $arr)
inherited

This function will order all the elements in one array, following the previous/next rules.

Parameters
array$arr
Return values
array|bool

◆ readableInfo()

xmldb_key::readableInfo ( )

Shows info in a readable format.

Return values
string

Reimplemented from xmldb_object.

◆ set_attributes()

xmldb_key::set_attributes ( $type,
$fields,
$reftable = null,
$reffields = null )

Set all the attributes of one xmldb_key.

Parameters
string$typeXMLDB_KEY_[PRIMARY|UNIQUE|FOREIGN|FOREIGN_UNIQUE]
array$fieldsan array of fieldnames to build the key over
string$reftablename of the table the FK points to or null
array$reffieldsan array of fieldnames in the FK table or null

◆ setChanged()

xmldb_object::setChanged ( $changed = true)
inherited

This function will set the changed field of the xmldb_object.

Parameters
bool$changed

◆ setComment()

xmldb_object::setComment ( $comment)
inherited

This function will set the comment of the xmldb_object.

Parameters
string$comment

◆ setFields()

xmldb_key::setFields ( $fields)

Set the key fields.

Parameters
array$fields

◆ setHash()

xmldb_object::setHash ( $hash)
inherited

This function will set the hash of the xmldb_object.

Parameters
string$hash

◆ setLoaded()

xmldb_object::setLoaded ( $loaded = true)
inherited

This function will set the loaded field of the xmldb_object.

Parameters
bool$loaded

◆ setName()

xmldb_object::setName ( $name)
inherited

This function will set the name field of the xmldb_object.

Parameters
string$name

◆ setNext()

xmldb_object::setNext ( $next)
inherited

This function will set the next of the xmldb_object.

Parameters
string$next

◆ setPrevious()

xmldb_object::setPrevious ( $previous)
inherited

This function will set the previous of the xmldb_object.

Parameters
string$previous

◆ setRefFields()

xmldb_key::setRefFields ( $reffields)

Set the key reffields.

Parameters
array$reffields

◆ setRefTable()

xmldb_key::setRefTable ( $reftable)

Set the key reftable.

Parameters
string$reftable

◆ setType()

xmldb_key::setType ( $type)

Set the key type.

Parameters
int$type

◆ validateDefinition()

xmldb_object::validateDefinition ( xmldb_table $xmldb_table = null)
inherited

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!

Parameters
xmldb_table$xmldb_tableoptional when object is table
Return values
stringnull if ok, error message if problem found

Reimplemented in xmldb_field, xmldb_index, and xmldb_table.

◆ xmlOutput()

xmldb_key::xmlOutput ( )

This function will output the XML text for one key.

Return values
string

The documentation for this class was generated from the following file: