Represent a field of a DAO object / Database column

package salt\dao

 Methods

Set default options for displaying the object with Base::FORM

displayOptions(array<mixed,mixed> $options) : \salt\Field

Parameters

$options

array<mixed,mixed>

parameters to use for displaying the field with FORM. key=>value

Returns

\salt\Fieldthis object

Check field is a date type

isDate() : boolean

Returns

booleanTRUE if the field is a date

Create a Field that contains a boolean

newBoolean(string $name, string $text, boolean $nullable = FALSE, mixed $defaultValue = NULL, string $useName = NULL
Static

Parameters

$name

string

column name

$text

string

literal description of the column.

$nullable

boolean

(optional, FALSE) TRUE if the field can be NULL : set an empty string for set a NULL. Explicit set EMPTY_STRING for set an empty string

$defaultValue

mixed

(optional, NULL) default value for new created object

$useName

string

(optional, NULL) in case $name is a reserved word, $useName will be used instead for DAO (obviously $name is still used in query SQL text)

Create a new Field from the current Field with some change. Every parameter can be NULL for keeping previous value

newClone(string $name = NULL, string $text = NULL, string $nullable = NULL, string $defaultValue = NULL, string $values = NULL) : \salt\Field

Parameters

$name

string

the new name

$text

string

the new text

$nullable

string

the new value for nullable behavior

$defaultValue

string

the new default value

$values

string

the new values list

Returns

\salt\Fielda new instance of Field with parameters

Create a Field that contains a date

newDate(string $name, string $text, string $sqlFormat, string $displayFormat = DEFAULT_DATE_DISPLAY_FORMAT, boolean $nullable = FALSE, mixed $defaultValue = NULL, string $useName = NULL
Static

Parameters

$name

string

column name

$text

string

literal description of the column.

$sqlFormat

string

(optional, NULL) SqlDateFormat or Mysql date format for date type field

$displayFormat

string

(optional, DEFAULT_DATE_DISPLAY_FORMAT) PHP date() format for display date type field

$nullable

boolean

(optional, FALSE) TRUE if the field can be NULL : set an empty string for set a NULL. Explicit set EMPTY_STRING for set an empty string

$defaultValue

mixed

(optional, NULL) default value for new created object

$useName

string

(optional, NULL) in case $name is a reserved word, $useName will be used instead for DAO (obviously $name is still used in query SQL text)

Create a Field that contains a number

newNumber(string $name, string $text, boolean $nullable = FALSE, integer $defaultValue = NULL, array<mixed,mixed> $values = array(), string $useName = NULL
Static

Parameters

$name

string

column name

$text

string

literal description of the column. Displayed in column header

$nullable

boolean

(optional, FALSE) TRUE if the field can be NULL : set an empty string for set a NULL. Explicit set EMPTY_STRING for set an empty string

$defaultValue

integer

(optional, NULL) default value for new created object

$values

array<mixed,mixed>

(optional, array()) List of all possible values for the field : number => mixed

$useName

string

(optional, NULL) in case $name is a reserved word, $useName will be used instead for DAO (obviously $name is still used in query SQL text)

Create a Field that contains a text

newText(string $name, string $text, boolean $nullable = FALSE, mixed $defaultValue = NULL, array<mixed,mixed> $values = array(), string $useName = NULL
Static

Parameters

$name

string

column name

$text

string

literal description of the column.

$nullable

boolean

(optional, FALSE) TRUE if the field can be NULL : set an empty string for set a NULL. Explicit set EMPTY_STRING for set an empty string

$defaultValue

mixed

(optional, NULL) default value for new created object

$values

array<mixed,mixed>

(optional, array()) List of all possible values for the field

$useName

string

(optional, NULL) in case $name is a reserved word, $useName will be used instead for DAO (obviously $name is still used in query SQL text)

Set a SQL text for creating table with exact type

sqlType(string $sqlType) : \salt\Field

Parameters

$sqlType

string

SQL type with lenght and other options : primary, unique, auto_increment, etc...

Returns

\salt\Fieldthis object

Check the value is valid for this field.

validate(mixed $value) 

Parameters

$value

mixed

Exceptions

\salt\SaltException if $value is not valid.

Create a new Field. Use static functions new.

__construct(string $name, string $text, integer $type, boolean $nullable = FALSE, mixed $defaultValue = NULL, array<mixed,mixed> $values = array(), string $sqlFormat = NULL, string $displayFormat = DEFAULT_DATE_DISPLAY_FORMAT, string $useName = NULL

..() for that

Parameters

$name

string

column name

$text

string

literal description of the column.

$type

integer

FieldType type of the field

$nullable

boolean

(optional, FALSE) TRUE if the field can be NULL : set an empty string for set a NULL. Explicit set EMPTY_STRING for set an empty string

$defaultValue

mixed

(optional, NULL) default value for new created object

$values

array<mixed,mixed>

(optional, array()) List of all possible values for the field

$sqlFormat

string

(optional, NULL) SqlDateFormat or Mysql date format for date type field

$displayFormat

string

(optional, DEFAULT_DATE_DISPLAY_FORMAT) PHP date() format for display date type field

$useName

string

(optional, NULL) in case $name is a reserved word, $useName will be used instead for DAO (obviously $name is still used in query SQL text)

 Properties

 

default value of the field.

$defaultValue : mixed

Default

NULL
 

default date format display for PHP date() function

$displayFormat : string

Default

NULL
see
 

attribute=>value for FORM display of the field

$displayOptions : array<mixed,mixed>

Default

array()
 

SqlDateFormat constant or other value : store format for DB, used for DATE type fields

$format : string

Default

NULL
 

column name

$name : string

Default

 

TRUE if field can be NULL

$nullable : boolean

Default

FALSE
 

SQL type for field creation if table does not exists.

$sqlType : string

Default

NULL
 

description, used by DAOConverter for display the name of the field

$text : string

Default

 

FieldType constant : type of the field

$type : integer

Default

 

if $name is a reserved word, the $useName can be used instead.

$useName : string

Default

NULL
 

List of possible values for the field

$values : array<mixed,mixed>

Default

array()
content value => text
 

list of Base special field names

$BASE_FIELDS : array<mixed,string>

Default

array('FORM', 'VIEW', 'COLUMN', 'SQL')
Static
 

list of all reserved field names

$RESERVED_FIELDS : array<mixed,string>

Default

NULL
Static

 Constants

 

Can be used to set a field to an empty string (''). All empty string are converted to NULL

EMPTY_STRING = "\1EMPTY_STRING\2"