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

Public Member Functions

 __construct ($name)
 Creates one new xmldb_table. More...
 
 add_field ($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null)
 This function will add one new field to the table with all its attributes defined. More...
 
 add_index ($name, $type, $fields, $hints=array())
 This function will add one new index to the table with all its attributes defined. More...
 
 add_key ($name, $type, $fields, $reftable=null, $reffields=null)
 This function will add one new key to the table with all its attributes defined. More...
 
 addField ($field, $after=null)
 Add one field to the table, allowing to specify the desired order If it's not specified, then the field is added at the end. More...
 
 addIndex ($index, $after=null)
 Add one index to the table, allowing to specify the desired order If it's not specified, then the index is added at the end. More...
 
 addKey ($key, $after=null)
 Add one key to the table, allowing to specify the desired order If it's not specified, then the key is added at the end. More...
 
 arr2xmldb_table ($xmlarr)
 Load data from XML to the table. More...
 
 calculateHash ($recursive=false)
 This function calculate and set the hash of one xmldb_table. More...
 
 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...
 
 deleteField ($fieldname)
 Delete one field from the table. More...
 
 deleteIndex ($indexname)
 Delete one index from the table. More...
 
 deleteKey ($keyname)
 Delete one key from the table. More...
 
 findFieldInArray ($fieldname)
 Returns the position of one field in the array. More...
 
 findIndexInArray ($indexname)
 Returns the position of one index in the array. More...
 
 findKeyInArray ($keyname)
 Returns the position of one key in the array. More...
 
 findObjectInArray ($objectname, $arr)
 Returns the position of one object in the array. More...
 
 fixPrevNext (&$arr)
 Reconstruct previous/next attributes. More...
 
 getAllErrors ()
 This function will return all the errors found in one table looking recursively inside each field/key/index. More...
 
 getComment ()
 This function returns the comment of one xmldb_object. More...
 
 getError ()
 This function will return the error detected in the object. More...
 
 getField ($fieldname)
 Returns one xmldb_field. More...
 
 getFields ()
 This function will return the array of fields in the table. More...
 
 getHash ()
 This function returns the hash of one xmldb_object. More...
 
 getIndex ($indexname)
 Returns one xmldb_index. More...
 
 getIndexes ()
 This function will return the array of indexes in the table. More...
 
 getKey ($keyname)
 Returns one xmldb_key. More...
 
 getKeys ()
 This function will return the array of keys in the table. 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...
 
 getPrevious ()
 This function will return the name of the previous xmldb_object. 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...
 
 orderFields ()
 This function will reorder the array of fields. More...
 
 orderIndexes ()
 This function will reorder the array of indexes. More...
 
 orderKeys ()
 This function will reorder the array of keys. More...
 
 readableInfo ()
 This function will display a readable info about the xmldb_object (should be implemented inside each XMLDBxxx object) 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)
 This function will set the array of fields in the table. More...
 
 setHash ($hash)
 This function will set the hash of the xmldb_object. More...
 
 setIndexes ($indexes)
 This function will set the array of indexes in the table. More...
 
 setKeys ($keys)
 This function will set the array of keys in the table. 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...
 
 validateDefinition (xmldb_table $xmldb_table=null)
 Validates the table restrictions (does not validate child elements). More...
 
 xmlOutput ()
 This function will output the XML text for one table. More...
 

Public Attributes

const NAME_MAX_LENGTH = 28
 Note: More...
 

Protected Attributes

bool $changed
 was object changed
 
string $comment
 comment on object
 
string $errormsg
 error message
 
xmldb_field[] $fields
 table columns
 
string $hash
 hash of object
 
xmldb_index[] $indexes
 indexes
 
xmldb_key[] $keys
 keys
 
bool $loaded
 is it loaded yet
 
string $name
 name of obejct
 
xmldb_object $next
 
xmldb_object $previous
 

Constructor & Destructor Documentation

◆ __construct()

xmldb_table::__construct (   $name)

Creates one new xmldb_table.

Parameters
string$name

Reimplemented from xmldb_object.

Member Function Documentation

◆ add_field()

xmldb_table::add_field (   $name,
  $type,
  $precision = null,
  $unsigned = null,
  $notnull = null,
  $sequence = null,
  $default = null,
  $previous = null 
)

This function will add one new field to the table with all its attributes defined.

Parameters
string$namename of the field
int$typeXMLDB_TYPE_INTEGER, XMLDB_TYPE_NUMBER, XMLDB_TYPE_CHAR, XMLDB_TYPE_TEXT, XMLDB_TYPE_BINARY
string$precisionlength for integers and chars, two-comma separated numbers for numbers
bool$unsignedXMLDB_UNSIGNED or null (or false)
bool$notnullXMLDB_NOTNULL or null (or false)
bool$sequenceXMLDB_SEQUENCE or null (or false)
mixed$defaultmeaningful default o null (or false)
xmldb_object$previousname of the previous field in the table or null (or false)
Return values
xmlddb_field

◆ add_index()

xmldb_table::add_index (   $name,
  $type,
  $fields,
  $hints = array() 
)

This function will add one new index to the table with all its attributes defined.

Parameters
string$namename of the index
int$typeXMLDB_INDEX_UNIQUE, XMLDB_INDEX_NOTUNIQUE
array$fieldsan array of fieldnames to build the index over
array$hintsoptional index type hints

◆ add_key()

xmldb_table::add_key (   $name,
  $type,
  $fields,
  $reftable = null,
  $reffields = null 
)

This function will add one new key to the table with all its attributes defined.

Parameters
string$namename of the key
int$typeXMLDB_KEY_PRIMARY, XMLDB_KEY_UNIQUE, XMLDB_KEY_FOREIGN
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

◆ addField()

xmldb_table::addField (   $field,
  $after = null 
)

Add one field to the table, allowing to specify the desired order If it's not specified, then the field is added at the end.

Parameters
xmldb_field$field
xmldb_object$after
Return values
xmldb_field

◆ addIndex()

xmldb_table::addIndex (   $index,
  $after = null 
)

Add one index to the table, allowing to specify the desired order If it's not specified, then the index is added at the end.

Parameters
xmldb_index$index
xmldb_object$after

◆ addKey()

xmldb_table::addKey (   $key,
  $after = null 
)

Add one key to the table, allowing to specify the desired order If it's not specified, then the key is added at the end.

Parameters
xmldb_key$key
xmldb_object$after

◆ arr2xmldb_table()

xmldb_table::arr2xmldb_table (   $xmlarr)

Load data from XML to the table.

Parameters
array$xmlarr
Return values
boolsuccess

◆ calculateHash()

xmldb_table::calculateHash (   $recursive = false)

This function calculate and set the hash of one xmldb_table.

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

◆ deleteField()

xmldb_table::deleteField (   $fieldname)

Delete one field from the table.

Parameters
string$fieldname

◆ deleteIndex()

xmldb_table::deleteIndex (   $indexname)

Delete one index from the table.

Parameters
string$indexname

◆ deleteKey()

xmldb_table::deleteKey (   $keyname)

Delete one key from the table.

Parameters
string$keyname

◆ findFieldInArray()

xmldb_table::findFieldInArray (   $fieldname)

Returns the position of one field in the array.

Parameters
string$fieldname
Return values
int|nullindex of the field, or null if not found.

◆ findIndexInArray()

xmldb_table::findIndexInArray (   $indexname)

Returns the position of one index in the array.

Parameters
string$indexname
Return values
int|nullindex of the index, or null if not found.

◆ findKeyInArray()

xmldb_table::findKeyInArray (   $keyname)

Returns the position of one key in the array.

Parameters
string$keyname
Return values
int|nullindex of the key, or null if not found.

◆ 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

◆ getAllErrors()

xmldb_table::getAllErrors ( )

This function will return all the errors found in one table looking recursively inside each field/key/index.

Returns an array of errors or false

◆ 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

◆ getField()

xmldb_table::getField (   $fieldname)

Returns one xmldb_field.

Parameters
string$fieldname
Return values
xmldb_field|null

◆ getFields()

xmldb_table::getFields ( )

This function will return the array of fields in the table.

Return values
xmldb_field[]

◆ getHash()

xmldb_object::getHash ( )
inherited

This function returns the hash of one xmldb_object.

Return values
string

◆ getIndex()

xmldb_table::getIndex (   $indexname)

Returns one xmldb_index.

Parameters
string$indexname
Return values
xmldb_index|null

◆ getIndexes()

xmldb_table::getIndexes ( )

This function will return the array of indexes in the table.

Return values
xmldb_index[]

◆ getKey()

xmldb_table::getKey (   $keyname)

Returns one xmldb_key.

Parameters
string$keyname
Return values
xmldb_key|null

◆ getKeys()

xmldb_table::getKeys ( )

This function will return the array of keys in the table.

Return values
xmldb_key[]

◆ 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

◆ getPrevious()

xmldb_object::getPrevious ( )
inherited

This function will return the name of the previous xmldb_object.

Return values
xmldb_object

◆ 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

◆ orderFields()

xmldb_table::orderFields ( )

This function will reorder the array of fields.

Return values
boolwhether the reordering succeeded.

◆ orderIndexes()

xmldb_table::orderIndexes ( )

This function will reorder the array of indexes.

Return values
boolwhether the reordering succeeded.

◆ orderKeys()

xmldb_table::orderKeys ( )

This function will reorder the array of keys.

Return values
boolwhether the reordering succeeded.

◆ readableInfo()

xmldb_object::readableInfo ( )
inherited

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

Return values
string

Reimplemented in xmldb_key, xmldb_index, and xmldb_field.

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

This function will set the array of fields in the table.

Parameters
xmldb_field[]$fields

◆ setHash()

xmldb_object::setHash (   $hash)
inherited

This function will set the hash of the xmldb_object.

Parameters
string$hash

◆ setIndexes()

xmldb_table::setIndexes (   $indexes)

This function will set the array of indexes in the table.

Parameters
xmldb_index[]$indexes

◆ setKeys()

xmldb_table::setKeys (   $keys)

This function will set the array of keys in the table.

Parameters
xmldb_key[]$keys

◆ 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

◆ validateDefinition()

xmldb_table::validateDefinition ( xmldb_table  $xmldb_table = null)

Validates the table restrictions (does not validate child elements).

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_table::xmlOutput ( )

This function will output the XML text for one table.

Return values
string

Member Data Documentation

◆ NAME_MAX_LENGTH

const xmldb_table::NAME_MAX_LENGTH = 28

Note:

  • Oracle has 30 chars limit for all names, 2 chars are reserved for prefix.

@const maximum length of field names


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