|
Moodle
2.2.1
http://www.collinsharper.com
|
This class represent one XMLDB Field. More...


Public Member Functions | |
| __construct ($name, $type=null, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) | |
| setAttributes ($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) | |
| set_attributes ($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) | |
| Deprecated API ends here. | |
| getType () | |
| getLength () | |
| getDecimals () | |
| getNotNull () | |
| getUnsigned () | |
| getSequence () | |
| getDefault () | |
| setType ($type) | |
| setLength ($length) | |
| setDecimals ($decimals) | |
| setUnsigned ($unsigned=true) | |
| setNotNull ($notnull=true) | |
| setSequence ($sequence=true) | |
| setDefault ($default) | |
| arr2xmldb_field ($xmlarr) | |
| getXMLDBFieldType ($type) | |
| getXMLDBTypeName ($type) | |
| calculateHash ($recursive=false) | |
| xmlOutput () | |
| setFromADOField ($adofield) | |
| getPHP ($includeprevious=true) | |
| readableInfo () | |
| validateDefinition (xmldb_table $xmldb_table=null) | |
Data Fields | |
| $type | |
| $length | |
| $unsigned | |
| $notnull | |
| $default | |
| $sequence | |
| $decimals | |
| const | CHAR_MAX_LENGTH = 1333 |
This class represent one XMLDB Field.
Definition at line 29 of file xmldb_field.php.
| __construct | ( | $ | name, |
| $ | type = null, |
||
| $ | precision = null, |
||
| $ | unsigned = null, |
||
| $ | notnull = null, |
||
| $ | sequence = null, |
||
| $ | default = null, |
||
| $ | previous = null |
||
| ) |
Creates one new xmldb_field
Definition at line 53 of file xmldb_field.php.

| arr2xmldb_field | ( | $ | xmlarr | ) |
Load data from XML to the table
Debug the table traverse_xmlize($xmlarr); //Debug print_object ($GLOBALS['traverse_array']); //Debug $GLOBALS['traverse_array']=""; //Debug
Process table attributes (name, type, length, unsigned, notnull, sequence, decimals, comment, previous, next)
Check for valid type
Check for integer values
Check for big, medium, small to be applied to text and binary
Finally, set the length
Check for integer values
TODO: Drop this check in Moodle 2.1 Detect if there is old enum information in the XML file
Set some attributes
Definition at line 223 of file xmldb_field.php.

| calculateHash | ( | $ | recursive = false | ) |
This function calculate and set the hash of one xmldb_field
Definition at line 468 of file xmldb_field.php.

| getDecimals | ( | ) |
Get the decimals
Definition at line 126 of file xmldb_field.php.

| getDefault | ( | ) |
Get the default
Definition at line 154 of file xmldb_field.php.

| getLength | ( | ) |
Get the length
Definition at line 119 of file xmldb_field.php.

| getNotNull | ( | ) |
Get the notnull
Definition at line 133 of file xmldb_field.php.

Returns the PHP code needed to define one xmldb_field
The XMLDBTYPE
The length
Unsigned (only applicable to numbers)
Not Null
Sequence
Default
Previous (decided by parameter)
Return result
Definition at line 656 of file xmldb_field.php.

| getSequence | ( | ) |
Get the sequence
Definition at line 147 of file xmldb_field.php.

| getType | ( | ) |
Get the type
Definition at line 112 of file xmldb_field.php.

| getUnsigned | ( | ) |
Get the unsigned
Definition at line 140 of file xmldb_field.php.

| getXMLDBFieldType | ( | $ | type | ) |
This function returns the correct XMLDB_TYPE_XXX value for the string passed as argument
Return the normalized XMLDB_TYPE
Definition at line 399 of file xmldb_field.php.

| getXMLDBTypeName | ( | $ | type | ) |
This function returns the correct name value for the XMLDB_TYPE_XXX passed as argument
Return the normalized name
Definition at line 434 of file xmldb_field.php.

| readableInfo | ( | ) |
Shows info in a readable format
type
length
unsigned
not null
default
sequence
Reimplemented from xmldb_object.
Definition at line 744 of file xmldb_field.php.

| set_attributes | ( | $ | type, |
| $ | precision = null, |
||
| $ | unsigned = null, |
||
| $ | notnull = null, |
||
| $ | sequence = null, |
||
| $ | default = null, |
||
| $ | previous = null |
||
| ) |
Deprecated API ends here.
Set all the attributes of one xmldb_field
| string | type XMLDB_TYPE_INTEGER, XMLDB_TYPE_NUMBER, XMLDB_TYPE_CHAR, XMLDB_TYPE_TEXT, XMLDB_TYPE_BINARY |
| string | precision length for integers and chars, two-comma separated numbers for numbers and 'small', 'medium', 'big' for texts and binaries |
| string | unsigned XMLDB_UNSIGNED or null (or false) |
| string | notnull XMLDB_NOTNULL or null (or false) |
| string | sequence XMLDB_SEQUENCE or null (or false) |
| string | default meaningful default o null (or false) |
Try to split the precision into length and decimals and apply each one as needed
Definition at line 89 of file xmldb_field.php.


| setAttributes | ( | $ | type, |
| $ | precision = null, |
||
| $ | unsigned = null, |
||
| $ | notnull = null, |
||
| $ | sequence = null, |
||
| $ | enum = null, |
||
| $ | enumvalues = null, |
||
| $ | default = null, |
||
| $ | previous = null |
||
| ) |
TODO: Delete for 2.1 (deprecated in 2.0). Deprecated API starts here
Definition at line 68 of file xmldb_field.php.

| setDecimals | ( | $ | decimals | ) |
Set the field decimals
Definition at line 175 of file xmldb_field.php.
| setDefault | ( | $ | default | ) |
Set the field default
Check, warn and auto-fix '' (empty) defaults for CHAR NOT NULL columns, changing them to NULL so XMLDB will apply the proper default
Check, warn and autofix TEXT|BINARY columns having a default clause (only null is allowed)
Definition at line 203 of file xmldb_field.php.


| setFromADOField | ( | $ | adofield | ) |
This function will set all the attributes of the xmldb_field object based on information passed in one ADOField
Calculate the XMLDB_TYPE
Calculate the length of the field
Calculate the decimals of the field
Calculate the unsigned field
Calculate the notnull field
Calculate the default field
Calculate the sequence field
Sequence fields are always unsigned
Some more fields
Definition at line 535 of file xmldb_field.php.
| setLength | ( | $ | length | ) |
Set the field length
Definition at line 168 of file xmldb_field.php.
| setNotNull | ( | $ | notnull = true | ) |
Set the field notnull
Definition at line 189 of file xmldb_field.php.
| setSequence | ( | $ | sequence = true | ) |
Set the field sequence
Definition at line 196 of file xmldb_field.php.
| setType | ( | $ | type | ) |
Set the field type
Definition at line 161 of file xmldb_field.php.
| setUnsigned | ( | $ | unsigned = true | ) |
Set the field unsigned
Definition at line 182 of file xmldb_field.php.
| 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!
| xmldb_table | $xmldb_table | optional when object is table |
Reimplemented from xmldb_object.
Definition at line 809 of file xmldb_field.php.

| xmlOutput | ( | ) |
This function will output the XML text for one field
Definition at line 482 of file xmldb_field.php.

| $decimals |
Definition at line 37 of file xmldb_field.php.
Definition at line 35 of file xmldb_field.php.
| $length |
Definition at line 32 of file xmldb_field.php.
| $notnull |
Definition at line 34 of file xmldb_field.php.
| $sequence |
Definition at line 36 of file xmldb_field.php.
| $type |
Definition at line 31 of file xmldb_field.php.
| $unsigned |
Definition at line 33 of file xmldb_field.php.
| const CHAR_MAX_LENGTH = 1333 |
Note:
maximum length of text field
Definition at line 48 of file xmldb_field.php.