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

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

Methods

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

Creates filtered and grouped table representation.

setActive(int $active)

Sets active group.

select($columns, ...$params)

No description

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

No description

mixed
aggregation(string $function)

No description

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 and grouped table representation.

Parameters

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

at line 53
GroupedSelection setActive(int $active)

Sets active group.

Parameters

int $active primary key of grouped rows

Return Value

GroupedSelection

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

Parameters

$columns
...$params

Return Value

Selection

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

Parameters

string $columns
...$params

Return Value

Selection

at line 93
mixed aggregation(string $function)

Parameters

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

Return Value

mixed

at line 121
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 131
protected void execute()

Return Value

void

at line 183
protected Selection getRefTable($refPath)

Returns Selection parent for caching.

Parameters

$refPath

Return Value

Selection

at line 196
protected void loadRefCache()

Loads refCache references

Return Value

void

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

Parameters

bool $saveCache
bool $deleteRererencedCache

Return Value

void

at line 218
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 236
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 249
int delete()

Deletes all rows in result set.

Return Value

int number of affected rows