Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Public Attributes | Protected Attributes | List of all members
xmldb_index Class Reference
Inheritance diagram for xmldb_index:
xmldb_object

Public Member Functions

 __construct ($name, $type=null, $fields=array(), $hints=array())
 Creates one new xmldb_index. More...
 
 arr2xmldb_index ($xmlarr)
 Load data from XML to the index. More...
 
 calculateHash ($recursive=false)
 This function calculate and set the hash of one xmldb_index @retur nvoid, changes $this->hash.
 
 checkName ()
 This function will check if one key name is ok or no (true/false) only lowercase a-z, 0-9 and _ are allowed. More...
 
 checkNameValues ($arr)
 This function will check that all the elements in one array have a correct name [a-z0-9_]. More...
 
 comma2array ($string)
 Returns one array of elements from one comma separated string, supporting quoted strings containing commas and concat function calls. More...
 
 debug ($message)
 This function will perform the central debug of all the XMLDB classes being called automatically every time one error is found. More...
 
 findObjectInArray ($objectname, $arr)
 Returns the position of one object in the array. More...
 
 fixPrevNext (&$arr)
 Reconstruct previous/next attributes. More...
 
 getComment ()
 This function returns the comment of one xmldb_object. More...
 
 getError ()
 This function will return the error detected in the object. More...
 
 getFields ()
 Get the index fields. More...
 
 getHash ()
 This function returns the hash of one xmldb_object. More...
 
 getHints ()
 Returns optional index hints. More...
 
 getName ()
 This function will return the name of the xmldb_object. More...
 
 getNext ()
 This function will return the name of the next xmldb_object. More...
 
 getPHP ()
 Returns the PHP code needed to define one xmldb_index. More...
 
 getPrevious ()
 This function will return the name of the previous xmldb_object. More...
 
 getUnique ()
 Get the index unique. More...
 
 hasChanged ()
 This function returns true/false, if the xmldb_object has changed. More...
 
 isLoaded ()
 This function returns true/false, if the xmldb_object has been loaded. More...
 
 orderElements ($arr)
 This function will order all the elements in one array, following the previous/next rules. More...
 
 readableInfo ()
 Shows info in a readable format. More...
 
 set_attributes ($type, $fields, $hints=array())
 Set all the attributes of one xmldb_index. More...
 
 setChanged ($changed=true)
 This function will set the changed field of the xmldb_object. More...
 
 setComment ($comment)
 This function will set the comment of the xmldb_object. More...
 
 setFields ($fields)
 Set the index fields. More...
 
 setFromADOIndex ($adoindex)
 This function will set all the attributes of the xmldb_index object based on information passed in one ADOindex. More...
 
 setHash ($hash)
 This function will set the hash of the xmldb_object. More...
 
 setHints ($hints)
 Set optional index hints. More...
 
 setLoaded ($loaded=true)
 This function will set the loaded field of the xmldb_object. More...
 
 setName ($name)
 This function will set the name field of the xmldb_object. More...
 
 setNext ($next)
 This function will set the next of the xmldb_object. More...
 
 setPrevious ($previous)
 This function will set the previous of the xmldb_object. More...
 
 setUnique ($unique=true)
 Set the index unique. More...
 
 validateDefinition (xmldb_table $xmldb_table=null)
 Validates the index restrictions. More...
 
 xmlOutput ()
 This function will output the XML text for one index. More...
 

Public Attributes

const INDEX_COMPOSED_MAX_BYTES = 999
 Note: More...
 
const INDEX_MAX_BYTES = 765
 Note: More...
 

Protected Attributes

bool $changed
 was object changed
 
string $comment
 comment on object
 
string $errormsg
 error message
 
array $fields
 index fields
 
string $hash
 hash of object
 
array $hints
 index hints
 
bool $loaded
 is it loaded yet
 
string $name
 name of obejct
 
xmldb_object $next
 
xmldb_object $previous
 
bool $unique
 is unique?
 

Constructor & Destructor Documentation

◆ __construct()

xmldb_index::__construct (   $name,
  $type = null,
  $fields = array(),
  $hints = array() 
)

Creates one new xmldb_index.

Parameters
string$name
string$typeXMLDB_INDEX_UNIQUE, XMLDB_INDEX_NOTUNIQUE
array$fieldsan array of fieldnames to build the index over
array$hintsan array of optional hints

Member Function Documentation

◆ arr2xmldb_index()

xmldb_index::arr2xmldb_index (   $xmlarr)

Load data from XML to the index.

Parameters
$xmlarrarray
Return values
bool

◆ 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_index::getFields ( )

Get the index fields.

Return values
array

◆ getHash()

xmldb_object::getHash ( )
inherited

This function returns the hash of one xmldb_object.

Return values
string

◆ getHints()

xmldb_index::getHints ( )

Returns optional index hints.

Return values
array

◆ 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
xmldb_object

◆ getPHP()

xmldb_index::getPHP ( )

Returns the PHP code needed to define one xmldb_index.

Return values
string

◆ getPrevious()

xmldb_object::getPrevious ( )
inherited

This function will return the name of the previous xmldb_object.

Return values
xmldb_object

◆ getUnique()

xmldb_index::getUnique ( )

Get the index unique.

Return values
bool

◆ 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_index::readableInfo ( )

Shows info in a readable format.

Return values
string

Reimplemented from xmldb_object.

◆ set_attributes()

xmldb_index::set_attributes (   $type,
  $fields,
  $hints = array() 
)

Set all the attributes of one xmldb_index.

Parameters
stringtype XMLDB_INDEX_UNIQUE, XMLDB_INDEX_NOTUNIQUE
arrayfields an array of fieldnames to build the index over
array$hintsarray of optional hints

◆ 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_index::setFields (   $fields)

Set the index fields.

Parameters
array$fields

◆ setFromADOIndex()

xmldb_index::setFromADOIndex (   $adoindex)

This function will set all the attributes of the xmldb_index object based on information passed in one ADOindex.

Parameters
array
Return values
void

◆ setHash()

xmldb_object::setHash (   $hash)
inherited

This function will set the hash of the xmldb_object.

Parameters
string$hash

◆ setHints()

xmldb_index::setHints (   $hints)

Set optional index hints.

Parameters
array$hints

◆ 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
xmldb_object$next

◆ setPrevious()

xmldb_object::setPrevious (   $previous)
inherited

This function will set the previous of the xmldb_object.

Parameters
xmldb_object$previous

◆ setUnique()

xmldb_index::setUnique (   $unique = true)

Set the index unique.

Parameters
bool$unique

◆ validateDefinition()

xmldb_index::validateDefinition ( xmldb_table  $xmldb_table = null)

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!

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

Reimplemented from xmldb_object.

◆ xmlOutput()

xmldb_index::xmlOutput ( )

This function will output the XML text for one index.

Return values
string

Member Data Documentation

◆ INDEX_COMPOSED_MAX_BYTES

const xmldb_index::INDEX_COMPOSED_MAX_BYTES = 999

Note:

  • MySQL: MyISAM has a limit of 1000 bytes for any key including composed, InnoDB has limit 3500 bytes.

@const max length of composed indexes, one utf-8 char is 3 bytes in the worst case

◆ INDEX_MAX_BYTES

const xmldb_index::INDEX_MAX_BYTES = 765

Note:

  • MySQL: InnoDB limits size of index on single column to 767bytes (256 chars)

@const single column index length limit, one utf-8 char is 3 bytes in the worst case


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