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

Public Member Functions

 __construct ($name, $type=null, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null)
 Creates one new xmldb_field. More...
 
 arr2xmldb_field ($xmlarr)
 Load data from XML to the table. More...
 
 calculateHash ($recursive=false)
 This function calculate and set the hash of one xmldb_field. 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...
 
 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...
 
 getDecimals ()
 Get the decimals. More...
 
 getDefault ()
 Get the default. More...
 
 getError ()
 This function will return the error detected in the object. More...
 
 getHash ()
 This function returns the hash of one xmldb_object. More...
 
 getLength ()
 Get the length. 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...
 
 getNotNull ()
 Get the notnull. More...
 
 getPHP ($includeprevious=true)
 Returns the PHP code needed to define one xmldb_field. More...
 
 getPrevious ()
 This function will return the name of the previous xmldb_object. More...
 
 getSequence ()
 Get the sequence. More...
 
 getType ()
 Get the type. More...
 
 getUnsigned ()
 Get the unsigned. More...
 
 getXMLDBFieldType ($type)
 This function returns the correct XMLDB_TYPE_XXX value for the string passed as argument. More...
 
 getXMLDBTypeName ($type)
 This function returns the correct name value for the XMLDB_TYPE_XXX passed as argument. 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, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null)
 Set all the attributes of one xmldb_field. 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...
 
 setDecimals ($decimals)
 Set the field decimals. More...
 
 setDefault ($default)
 Set the field default. More...
 
 setFromADOField ($adofield)
 This function will set all the attributes of the xmldb_field object based on information passed in one ADOField. More...
 
 setHash ($hash)
 This function will set the hash of the xmldb_object. More...
 
 setLength ($length)
 Set the field length. 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...
 
 setNotNull ($notnull=true)
 Set the field notnull. More...
 
 setPrevious ($previous)
 This function will set the previous of the xmldb_object. More...
 
 setSequence ($sequence=true)
 Set the field sequence. More...
 
 setType ($type)
 Set the field type. More...
 
 setUnsigned ($unsigned=true)
 Set the field unsigned. More...
 
 validateDefinition (xmldb_table $xmldb_table=null)
 Validates the field restrictions. More...
 
 xmlOutput ()
 This function will output the XML text for one field. More...
 

Public Attributes

const CHAR_MAX_LENGTH = 1333
 Note: More...
 
const FLOAT_MAX_LENGTH = 20
 @const max length of floats
 
const INTEGER_MAX_LENGTH = 20
 @const maximum number of digits of integers
 
const NAME_MAX_LENGTH = 30
 Note: More...
 
const NUMBER_MAX_LENGTH = 38
 @const max length (precision, the total number of digits) of decimals
 

Protected Attributes

bool $changed
 was object changed
 
string $comment
 comment on object
 
int $decimals
 number of decimals
 
mixed $default
 default value
 
string $errormsg
 error message
 
string $hash
 hash of object
 
int $length
 size of field
 
bool $loaded
 is it loaded yet
 
string $name
 name of obejct
 
xmldb_object $next
 
bool $notnull
 is null forbidden? XMLDB_NOTNULL
 
xmldb_object $previous
 
bool $sequence
 use automatic counter
 
int $type
 XMLDB_TYPE_ constants.
 

Constructor & Destructor Documentation

◆ __construct()

xmldb_field::__construct (   $name,
  $type = null,
  $precision = null,
  $unsigned = null,
  $notnull = null,
  $sequence = null,
  $default = null,
  $previous = null 
)

Creates one new xmldb_field.

Parameters
string$nameof 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$previous

Member Function Documentation

◆ arr2xmldb_field()

xmldb_field::arr2xmldb_field (   $xmlarr)

Load data from XML to the table.

Parameters
array$xmlarr
Return values
mixed

◆ calculateHash()

xmldb_field::calculateHash (   $recursive = false)

This function calculate and set the hash of one xmldb_field.

Parameters
bool$recursive
Return values
void,modifies::$this-,>hash

◆ 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

◆ getDecimals()

xmldb_field::getDecimals ( )

Get the decimals.

Return values
string

◆ getDefault()

xmldb_field::getDefault ( )

Get the default.

Return values
mixed

◆ getError()

xmldb_object::getError ( )
inherited

This function will return the error detected in the object.

Return values
string

◆ getHash()

xmldb_object::getHash ( )
inherited

This function returns the hash of one xmldb_object.

Return values
string

◆ getLength()

xmldb_field::getLength ( )

Get the length.

Return values
int

◆ 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

◆ getNotNull()

xmldb_field::getNotNull ( )

Get the notnull.

Return values
bool

◆ getPHP()

xmldb_field::getPHP (   $includeprevious = true)

Returns the PHP code needed to define one xmldb_field.

Parameters
bool$includeprevious
Return values
string

◆ getPrevious()

xmldb_object::getPrevious ( )
inherited

This function will return the name of the previous xmldb_object.

Return values
xmldb_object

◆ getSequence()

xmldb_field::getSequence ( )

Get the sequence.

Return values
bool

◆ getType()

xmldb_field::getType ( )

Get the type.

Return values
int

◆ getUnsigned()

xmldb_field::getUnsigned ( )

Get the unsigned.

Deprecated:
since moodle 2.3
Return values
bool

◆ getXMLDBFieldType()

xmldb_field::getXMLDBFieldType (   $type)

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

Parameters
string$type
Return values
int

◆ getXMLDBTypeName()

xmldb_field::getXMLDBTypeName (   $type)

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

Parameters
int$type
Return values
string

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

Shows info in a readable format.

Return values
string

Reimplemented from xmldb_object.

◆ set_attributes()

xmldb_field::set_attributes (   $type,
  $precision = null,
  $unsigned = null,
  $notnull = null,
  $sequence = null,
  $default = null,
  $previous = null 
)

Set all the attributes of one xmldb_field.

Parameters
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$previous

◆ 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

◆ setDecimals()

xmldb_field::setDecimals (   $decimals)

Set the field decimals.

Parameters
string

◆ setDefault()

xmldb_field::setDefault (   $default)

Set the field default.

Parameters
mixed$default

◆ setFromADOField()

xmldb_field::setFromADOField (   $adofield)

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

Parameters
string$adofield
Return values
void,sets::$this-,>type

◆ setHash()

xmldb_object::setHash (   $hash)
inherited

This function will set the hash of the xmldb_object.

Parameters
string$hash

◆ setLength()

xmldb_field::setLength (   $length)

Set the field length.

Parameters
int$length

◆ 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

◆ setNotNull()

xmldb_field::setNotNull (   $notnull = true)

Set the field notnull.

Parameters
bool$notnull

◆ setPrevious()

xmldb_object::setPrevious (   $previous)
inherited

This function will set the previous of the xmldb_object.

Parameters
xmldb_object$previous

◆ setSequence()

xmldb_field::setSequence (   $sequence = true)

Set the field sequence.

Parameters
bool$sequence

◆ setType()

xmldb_field::setType (   $type)

Set the field type.

Parameters
int$type

◆ setUnsigned()

xmldb_field::setUnsigned (   $unsigned = true)

Set the field unsigned.

Deprecated:
since moodle 2.3
Parameters
bool$unsigned

◆ validateDefinition()

xmldb_field::validateDefinition ( xmldb_table  $xmldb_table = null)

Validates the field 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_field::xmlOutput ( )

This function will output the XML text for one field.

Return values
string

Member Data Documentation

◆ CHAR_MAX_LENGTH

const xmldb_field::CHAR_MAX_LENGTH = 1333

Note:

  • Oracle: VARCHAR2 has a limit of 4000 bytes
  • SQL Server: NVARCHAR has a limit of 40000 chars
  • MySQL: VARCHAR 65,535 chars
  • PostgreSQL: no limit

@const maximum length of text field

◆ NAME_MAX_LENGTH

const xmldb_field::NAME_MAX_LENGTH = 30

Note:

  • Oracle has 30 chars limit for all names

@const maximumn length of field names


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