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(Explorer $explorer, Conventions $conventions, string $tableName, string $column, Selection $refTable, IStorage $cacheStorage = null)

Creates filtered and grouped table representation.

setActive(int|string $active)

Sets active group.

select(string|string[] $columns, ...$params)

No description

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

No description

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

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(Explorer $explorer, Conventions $conventions, string $tableName, string $column, Selection $refTable, IStorage $cacheStorage = null)

Creates filtered and grouped table representation.

Parameters

Explorer $explorer
Conventions $conventions
string $tableName
string $column
Selection $refTable
IStorage $cacheStorage

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

internal  
 

Sets active group.

Parameters

int|string $active

primary key of grouped rows

Return Value

GroupedSelection

at line 69
Selection select(string|string[] $columns, ...$params)

No description

Parameters

string|string[] $columns

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

...$params

Return Value

Selection

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

No description

Parameters

string $columns

for example 'column1, column2 DESC'

...$params

Return Value

Selection

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

No description

Parameters

string $function

select call in "FUNCTION(column)" format

string $groupFunction

Return Value

mixed

at line 135
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 145
protected void execute()

No description

Return Value

void

at line 202
protected Selection getRefTable($refPath)

Returns Selection parent for caching.

Parameters

$refPath

Return Value

Selection

at line 215
protected void loadRefCache()

Loads refCache references

Return Value

void

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

No description

Parameters

bool $saveCache
bool $deleteRererencedCache

Return Value

void

at line 240
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 ActiveRow or number of affected rows for Selection or table without primary key

at line 258
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 271
int delete()

Deletes all rows in result set.

Return Value

int

number of affected rows