class GroupedSelection extends Selection

Representation of filtered table grouped by some column.

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

Properties

protected Selection $refTable
protected mixed $refCacheCurrent
protected string $column
protected int $active

Methods

__construct(Context $context, IConventions $conventions, string $tableName, string $column, Selection $refTable, IStorage $cacheStorage = null)

Creates filtered table representation.

setActive(int|string $active)

Sets active group.

select($columns, ...$params)

Adds select clause, more calls appends to the end.

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

Adds order clause, more calls appends to the end.

mixed
aggregation(string $function)

Executes aggregation function.

int
count(string $column = null)

Counts number of rows.

void
execute()

No description

getRefTable($refPath)

Returns Selection parent for caching.

void
loadRefCache()

Loads refCache references

void
emptyResultSet(bool $saveCache = true, bool $deleteRererencedCache = true)

No description

ActiveRow|int|bool
insert(iterable $data)

Inserts row in a table.

int
update(iterable $data)

Updates all rows in result set.

int
delete()

Deletes all rows in result set.

Details

at line 39
__construct(Context $context, IConventions $conventions, string $tableName, string $column, Selection $refTable, IStorage $cacheStorage = null)

Creates filtered table representation.

Parameters

Context $context
IConventions $conventions
string $tableName
string $column
Selection $refTable
IStorage $cacheStorage

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

Sets active group.

Parameters

int|string $active primary key of grouped rows

Return Value

GroupedSelection

at line 63
Selection select($columns, ...$params)

Adds select clause, more calls appends to the end.

Parameters

$columns
...$params

Return Value

Selection

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

Adds order clause, more calls appends to the end.

Parameters

string $columns
...$params

Return Value

Selection

at line 93
mixed aggregation(string $function)

Executes aggregation function.

Parameters

string $function select call in "FUNCTION(column)" format

Return Value

mixed

at line 120
int count(string $column = null)

Counts number of rows.

Parameters

string $column if it is not provided returns count of result rows, otherwise runs new sql counting query

Return Value

int

at line 130
protected void execute()

Return Value

void

at line 182
protected Selection getRefTable($refPath)

Returns Selection parent for caching.

Parameters

$refPath

Return Value

Selection

at line 195
protected void loadRefCache()

Loads refCache references

Return Value

void

at line 211
protected void emptyResultSet(bool $saveCache = true, bool $deleteRererencedCache = true)

Parameters

bool $saveCache
bool $deleteRererencedCache

Return Value

void

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

Inserts row in a table.

Parameters

iterable $data [$column => $value]|\Traversable|Selection for INSERT ... SELECT

Return Value

ActiveRow|int|bool Returns IRow or number of affected rows for Selection or table without primary key

at line 238
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 251
int delete()

Deletes all rows in result set.

Return Value

int number of affected rows