class GroupedSelection extends Selection

Represents filtered table grouped by referencing table.

GroupedSelection is based on the great library NotORM http://www.notorm.com written by Jakub Vrana.

Properties

protected $refCacheCurrent

current assigned referencing array

protected $active

primary key

Methods

__construct(Explorer $explorer, string $tableName, string $column, Selection $refTable)

Creates filtered and grouped table representation.

setActive(int|string $active)

Sets active group.

select(string $columns, mixed ...$params)

Adds a SELECT clause. Automatically prepends the grouping column if no select exists yet.

order(string $columns, mixed ...$params)

Adds an ORDER BY clause. Automatically prepends the grouping column (matching direction) to improve index utilization.

void
refreshData()

Invalidates cached data and forces reload on next access.

mixed
aggregation(string $function, string|null $groupFunction = null)

Calculates aggregation for this group.

int
count(string|null $column = null)

Returns count of fetched rows, or runs COUNT($column) query when column is specified.

void
execute()

No description

getRefTable(mixed $refPath)

No description

void
loadRefCache()

Initializes the reference cache for the current selection. Overridden by GroupedSelection.

void
emptyResultSet(bool $clearCache = true, bool $deleteReferencedCache = true)

No description

ActiveRow|array|int
insert(iterable $data)

No description

int
update(iterable $data)

Updates all rows matching current conditions. JOINs in UPDATE are supported only by MySQL.

int
delete()

Deletes all rows matching current conditions.

Details

at line 34
__construct(Explorer $explorer, string $tableName, string $column, Selection $refTable)

Creates filtered and grouped table representation.

Parameters

Explorer $explorer
string $tableName
string $column
Selection $refTable

at line 51
GroupedSelection setActive(int|string $active)

internal  
 

Sets active group.

Parameters

int|string $active

primary key of grouped rows

Return Value

GroupedSelection

at line 61
Selection select(string $columns, mixed ...$params)

Adds a SELECT clause. Automatically prepends the grouping column if no select exists yet.

Parameters

string $columns

for example "column, MD5(column) AS column_md5"

mixed ...$params

Return Value

Selection

at line 74
Selection order(string $columns, mixed ...$params)

Adds an ORDER BY clause. Automatically prepends the grouping column (matching direction) to improve index utilization.

Parameters

string $columns

for example 'column1, column2 DESC'

mixed ...$params

Return Value

Selection

at line 88
void refreshData()

Invalidates cached data and forces reload on next access.

Return Value

void

at line 101
mixed aggregation(string $function, string|null $groupFunction = null)

Calculates aggregation for this group.

Parameters

string $function

select call in "FUNCTION(column)" format

string|null $groupFunction

Return Value

mixed

at line 140
int count(string|null $column = null)

Returns count of fetched rows, or runs COUNT($column) query when column is specified.

Parameters

string|null $column

Return Value

int

at line 149
protected void execute()

No description

Return Value

void

at line 215
protected Selection getRefTable(mixed $refPath)

No description

Parameters

mixed $refPath

Return Value

Selection

at line 228
protected void loadRefCache()

Initializes the reference cache for the current selection. Overridden by GroupedSelection.

Return Value

void

at line 243
protected void emptyResultSet(bool $clearCache = true, bool $deleteReferencedCache = true)

No description

Parameters

bool $clearCache
bool $deleteReferencedCache

Return Value

void

at line 255
ActiveRow|array|int insert(iterable $data)

No description

Parameters

iterable $data

Return Value

ActiveRow|array|int

at line 274
int update(iterable $data)

Updates all rows matching current conditions. JOINs in UPDATE are supported only by MySQL.

Parameters

iterable $data

Return Value

int

number of affected rows

at line 287
int delete()

Deletes all rows matching current conditions.

Return Value

int

number of affected rows