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

referenced table

protected $refCacheCurrent

current assigned referencing array

protected $column

grouping column name

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, ...$params)

No description

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

No description

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

Calculates aggregation for this group.

int
count(string|null $column = null)

Counts number of rows. If column is not provided returns count of result rows, otherwise runs new sql counting query.

void
execute()

No description

getRefTable($refPath)

Returns Selection parent for caching.

void
loadRefCache()

Loads refCache references

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

No description

ActiveRow|array|int|bool
insert(iterable $data)

Inserts row in a table. Returns ActiveRow or number of affected rows for Selection or table without primary key.

int
update(iterable $data)

Updates all rows in result set.

int
delete()

Deletes all rows in result set.

Details

at line 38
__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 55
GroupedSelection setActive(int|string $active)

internal  
 

Sets active group.

Parameters

int|string $active

primary key of grouped rows

Return Value

GroupedSelection

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

No description

Parameters

string $columns
...$params

Return Value

Selection

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

No description

Parameters

string $columns
...$params

Return Value

Selection

at line 89
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 126
int count(string|null $column = null)

Counts number of rows. If column is not provided returns count of result rows, otherwise runs new sql counting query.

Parameters

string|null $column

Return Value

int

at line 135
protected void execute()

No description

Return Value

void

at line 195
protected Selection getRefTable($refPath)

Returns Selection parent for caching.

Parameters

$refPath

Return Value

Selection

at line 208
protected void loadRefCache()

Loads refCache references

Return Value

void

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

No description

Parameters

bool $clearCache
bool $deleteReferencedCache

Return Value

void

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

Inserts row in a table. Returns ActiveRow or number of affected rows for Selection or table without primary key.

Parameters

iterable $data

Return Value

ActiveRow|array|int|bool

at line 250
int update(iterable $data)

Updates all rows in result set.

Joins in UPDATE are supported only in MySQL

Parameters

iterable $data

Return Value

int

number of affected rows

at line 263
int delete()

Deletes all rows in result set.

Return Value

int

number of affected rows