interface Relation implements SS_List, Filterable, Sortable, Limitable

Abstract representation of a DB relation field, either saved or in memory

Below methods will be added in 5.x

Methods

array
toArray()

Returns all the items in the list in an array.

from SS_List
array
toNestedArray()

Returns the contents of the list as an array of maps.

from SS_List
add(mixed $item)

Adds an item to the list, making no guarantees about where it will appear.

from SS_List
remove(mixed $item)

Removes an item from the list.

from SS_List
mixed
first()

Returns the first item in the list.

from SS_List
mixed
last()

Returns the last item in the list.

from SS_List
Map
map(string $keyfield = 'ID', string $titlefield = 'Title')

Returns a map of a key field to a value field of all the items in the list.

from SS_List
mixed
find(string $key, mixed $value)

Returns the first item in the list where the key field is equal to the value.

from SS_List
array
column(string $colName = "ID")

Returns an array of a single field value for all items in the list.

from SS_List
$this
each(callable $callback)

Walks the list using the specified callback

from SS_List
bool
canFilterBy(string $by)

Returns TRUE if the list can be filtered by a given field expression.

filter()

Return a new instance of this list that only includes items with these charactaristics

filterAny()

Return a copy of this list which contains items matching any of these charactaristics.

exclude()

Return a new instance of this list that excludes any items with these charactaristics

filterByCallback(callable $callback)

Return a new instance of this list that excludes any items with these charactaristics Filter this List by a callback function. The function will be passed each record of the List in turn, and must return true for the record to be included. Returns the filtered list.

mixed
byID(int $id)

Return the first item with the given ID

byIDs(array $ids)

Filter this list to only contain the given Primary IDs

bool
canSortBy(string $by)

Returns TRUE if the list can be sorted by a field.

from Sortable
sort()

Return a new instance of this list that is sorted by one or more fields. You can either pass in a single field name and direction, or a map of field names to sort directions.

from Sortable
reverse()

Return a new instance of this list based on reversing the current sort.

from Sortable
limit(int $limit, int $offset)

Returns a new instance of this list where no more than $limit records are included.

from Limitable
setByIDList(array $idList)

Sets the ComponentSet to be the given ID list.

array
getIDList()

Returns an array with both the keys and values set to the IDs of the records in this list.

dbObject(string $fieldName)

Return the DBField object that represents the given field on the related class.

Relation
relation($relationName)

No description

Relation
forForeignID($id)

No description

string
dataClass()

No description

Details

in SS_List at line 20
array toArray()

Returns all the items in the list in an array.

Return Value

array

in SS_List at line 27
array toNestedArray()

Returns the contents of the list as an array of maps.

Return Value

array

in SS_List at line 35
add(mixed $item)

Adds an item to the list, making no guarantees about where it will appear.

Parameters

mixed $item

in SS_List at line 42
remove(mixed $item)

Removes an item from the list.

Parameters

mixed $item

in SS_List at line 49
mixed first()

Returns the first item in the list.

Return Value

mixed

in SS_List at line 56
mixed last()

Returns the last item in the list.

Return Value

mixed

in SS_List at line 66
Map map(string $keyfield = 'ID', string $titlefield = 'Title')

Returns a map of a key field to a value field of all the items in the list.

Parameters

string $keyfield
string $titlefield

Return Value

Map

in SS_List at line 76
mixed find(string $key, mixed $value)

Returns the first item in the list where the key field is equal to the value.

Parameters

string $key
mixed $value

Return Value

mixed

in SS_List at line 84
array column(string $colName = "ID")

Returns an array of a single field value for all items in the list.

Parameters

string $colName

Return Value

array

in SS_List at line 92
$this each(callable $callback)

Walks the list using the specified callback

Parameters

callable $callback

Return Value

$this

in Filterable at line 22
bool canFilterBy(string $by)

Returns TRUE if the list can be filtered by a given field expression.

Parameters

string $by

Return Value

bool

in Filterable at line 35
Filterable filter()

Return a new instance of this list that only includes items with these charactaristics

Return Value

Filterable

in Filterable at line 59
Filterable filterAny()

Return a copy of this list which contains items matching any of these charactaristics.

Return Value

Filterable

in Filterable at line 72
Filterable exclude()

Return a new instance of this list that excludes any items with these charactaristics

Return Value

Filterable

in Filterable at line 83
Filterable filterByCallback(callable $callback)

Return a new instance of this list that excludes any items with these charactaristics Filter this List by a callback function. The function will be passed each record of the List in turn, and must return true for the record to be included. Returns the filtered list.

Parameters

callable $callback

Return Value

Filterable

in Filterable at line 91
mixed byID(int $id)

Return the first item with the given ID

Parameters

int $id

Return Value

mixed

in Filterable at line 99
SS_List byIDs(array $ids)

Filter this list to only contain the given Primary IDs

Parameters

array $ids Array of integers

Return Value

SS_List

in Sortable at line 22
bool canSortBy(string $by)

Returns TRUE if the list can be sorted by a field.

Parameters

string $by

Return Value

bool

in Sortable at line 34
Sortable sort()

Return a new instance of this list that is sorted by one or more fields. You can either pass in a single field name and direction, or a map of field names to sort directions.

Return Value

Sortable

in Sortable at line 43
Sortable reverse()

Return a new instance of this list based on reversing the current sort.

Return Value

Sortable

in Limitable at line 25
Limitable limit(int $limit, int $offset)

Returns a new instance of this list where no more than $limit records are included.

If $offset is specified, then that many records at the beginning of the list will be skipped. This matches the behaviour of the SQL LIMIT clause.

Parameters

int $limit
int $offset

Return Value

Limitable

at line 25
setByIDList(array $idList)

Sets the ComponentSet to be the given ID list.

Records will be added and deleted as appropriate.

Parameters

array $idList List of IDs.

at line 34
array getIDList()

Returns an array with both the keys and values set to the IDs of the records in this list.

Does not return the IDs for unsaved DataObjects

Return Value

array

at line 42
DBField dbObject(string $fieldName)

Return the DBField object that represents the given field on the related class.

Parameters

string $fieldName Name of the field

Return Value

DBField The field as a DBField object

at line 16
Relation relation($relationName)

Parameters

$relationName

Return Value

Relation

at line 16
Relation forForeignID($id)

Parameters

$id

Return Value

Relation

at line 16
string dataClass()

Return Value

string