interface CompositeDBField (View source)

Apply this interface to any {@link DBField} that doesn't have a 1-1 mapping with a database field.

This includes multi-value fields and transformed fields

Methods

setValue(DBField|array $value, DataObject|array $record = null, bool $markChanged = true)

Set the value of this field in various formats.

writeToManipulation(array $manipulation)

Add the custom internal values to an INSERT or UPDATE request passed through the ORM with {@link DataObject->write()}.

addToQuery(SQLQuery $query)

Add all columns which are defined through {@link requireField()} and {@link $composite_db}, or any additional SQL that is required to get to these columns. Will mostly just write to the {@link SQLQuery->select} array.

array
compositeDatabaseFields()

Return array in the format of {@link $composite_db}.

bool
isChanged()

Determines if the field has been changed since its initialization.

bool
exists()

Determines if any of the properties in this field have a value, meaning at least one of them is not NULL.

Details

setValue(DBField|array $value, DataObject|array $record = null, bool $markChanged = true)

Set the value of this field in various formats.

Used by {@link DataObject->getField()}, {@link DataObject->setCastedField()} {@link DataObject->dbObject()} and {@link DataObject->write()}.

As this method is used both for initializing the field after construction, and actually changing its values, it needs a {@link $markChanged} parameter.

Parameters

DBField|array $value
DataObject|array $record

An array or object that this field is part of

bool $markChanged

Indicate wether this field should be marked changed. Set to FALSE if you are initializing this field after construction, rather than setting a new value.

writeToManipulation(array $manipulation)

Add the custom internal values to an INSERT or UPDATE request passed through the ORM with {@link DataObject->write()}.

Fields are added in $manipulation['fields']. Please ensure these fields are escaped for database insertion, as no further processing happens before running the query. Use {@link DBField->prepValueForDB()}. Ensure to write NULL or empty values as well to allow unsetting a previously set field. Use {@link DBField->nullValue()} for the appropriate type.

Parameters

array $manipulation

addToQuery(SQLQuery $query)

Add all columns which are defined through {@link requireField()} and {@link $composite_db}, or any additional SQL that is required to get to these columns. Will mostly just write to the {@link SQLQuery->select} array.

Parameters

SQLQuery $query

array compositeDatabaseFields()

Return array in the format of {@link $composite_db}.

Used by {@link DataObject->hasOwnDatabaseField()}.

Return Value

array

bool isChanged()

Determines if the field has been changed since its initialization.

Most likely relies on an internal flag thats changed when calling {@link setValue()} or any other custom setters on the object.

Return Value

bool

bool exists()

Determines if any of the properties in this field have a value, meaning at least one of them is not NULL.

Return Value

bool