Moodle  2.2.1
http://www.collinsharper.com
xmldb_field Class Reference

This class represent one XMLDB Field. More...

Inheritance diagram for xmldb_field:
Collaboration diagram for xmldb_field:

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

Detailed Description

This class represent one XMLDB Field.

Definition at line 29 of file xmldb_field.php.


Constructor & Destructor Documentation

__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.

Here is the call graph for this function:


Member Function Documentation

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.

Here is the call graph for this function:

calculateHash ( recursive = false)

This function calculate and set the hash of one xmldb_field

Definition at line 468 of file xmldb_field.php.

Here is the caller graph for this function:

Get the decimals

Definition at line 126 of file xmldb_field.php.

Here is the caller graph for this function:

Get the default

Definition at line 154 of file xmldb_field.php.

Here is the caller graph for this function:

getLength ( )

Get the length

Definition at line 119 of file xmldb_field.php.

Here is the caller graph for this function:

Get the notnull

Definition at line 133 of file xmldb_field.php.

Here is the caller graph for this function:

getPHP ( includeprevious = true)

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.

Here is the call graph for this function:

Get the sequence

Definition at line 147 of file xmldb_field.php.

Here is the caller graph for this function:

getType ( )

Get the type

Definition at line 112 of file xmldb_field.php.

Here is the caller graph for this function:

Get the unsigned

Definition at line 140 of file xmldb_field.php.

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

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.

Here is the call graph for this function:

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

Parameters:
stringtype XMLDB_TYPE_INTEGER, XMLDB_TYPE_NUMBER, XMLDB_TYPE_CHAR, XMLDB_TYPE_TEXT, XMLDB_TYPE_BINARY
stringprecision length for integers and chars, two-comma separated numbers for numbers and 'small', 'medium', 'big' for texts and binaries
stringunsigned XMLDB_UNSIGNED or null (or false)
stringnotnull XMLDB_NOTNULL or null (or false)
stringsequence XMLDB_SEQUENCE or null (or false)
stringdefault 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.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Here is the call graph for this function:

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.

Here is the call graph for this function:

Here is the caller graph for this function:

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!

Parameters:
xmldb_table$xmldb_tableoptional when object is table
Returns:
string null if ok, error message if problem found

Reimplemented from xmldb_object.

Definition at line 809 of file xmldb_field.php.

Here is the call graph for this function:

xmlOutput ( )

This function will output the XML text for one field

Definition at line 482 of file xmldb_field.php.

Here is the call graph for this function:


Field Documentation

$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:

  • 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

maximum length of text field

Definition at line 48 of file xmldb_field.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations