Selection
class Selection implements Iterator, IRowContainer, ArrayAccess, Countable
Filtered table representation.
Selection is based on the great library NotORM http://www.notorm.com written by Jakub Vrana.
Properties
protected Context | $context | ||
protected IConventions | $conventions | ||
protected Cache | $cache | ||
protected SqlBuilder | $sqlBuilder | ||
protected string | $name | ||
protected string|array|null | $primary | ||
protected string|bool | $primarySequence | ||
protected IRow[] | $rows | ||
protected IRow[] | $data | ||
protected bool | $dataRefreshed | ||
protected mixed | $globalRefCache | ||
protected mixed | $refCache | ||
protected string | $generalCacheKey | ||
protected string | $specificCacheKey | ||
protected array | $aggregation | ||
protected array | $accessedColumns | ||
protected array | $previousAccessedColumns | ||
protected bool | $observeCache | ||
protected array | $keys |
Methods
Creates filtered table representation.
No description
No description
No description
No description
No description
No description
No description
Loads cache of previous accessed columns and returns it.
No description
No description
Fetches single field.
No description
No description
No description
Adds condition for primary key.
Adds ON condition when joining specified table, more calls appends with AND.
Adds condition, more calls appends with AND.
Sets offset using page number, more calls rewrite old values.
Executes aggregation function.
Counts number of rows.
Returns minimum value from a column.
Returns maximum value from a column.
Returns sum of values in a column.
No description
No description
No description
No description
No description
Returns Selection parent for caching.
Loads refCache references
Returns general cache key independent on query parameters or sql limit Used e.g. for previously accessed columns caching
Returns object specific cache key dependent on query parameters Used e.g. for reference memory caching
No description
No description
Returns if selection requeried for more columns.
Updates all rows in result set.
Deletes all rows in result set.
Returns referencing rows.
No description
No description
No description
No description
Mimic row.
Tests if row exists.
Removes row from result set.
Details
at line 88
__construct(Context $context, IConventions $conventions, $tableName, IStorage $cacheStorage = null)
Creates filtered table representation.
at line 101
__destruct()
No description
at line 107
__clone()
No description
at line 116
string
getName()
No description
at line 126
string|array|null
getPrimary($throw = true)
No description
at line 138
string|null
getPrimarySequence()
No description
at line 152
Selection
setPrimarySequence($sequence)
No description
at line 162
string
getSql()
No description
at line 173
array|false
getPreviousAccessedColumns()
internal |
Loads cache of previous accessed columns and returns it.
at line 190
SqlBuilder
getSqlBuilder()
internal |
No description
at line 204
ActiveRow|false
get($key)
Returns row specified by primary key.
at line 215
IRow|bool
fetch()
No description
at line 229
mixed|false
fetchField($column = null)
Fetches single field.
at line 247
array
fetchPairs($key = null, $value = null)
No description
at line 256
IRow[]
fetchAll()
No description
at line 265
array
fetchAssoc($path)
No description
at line 280
Selection
select($columns, ...$params)
Adds select clause, more calls appends to the end.
at line 293
Selection
wherePrimary($key)
Adds condition for primary key.
at line 319
Selection
where($condition, ...$params)
Adds where condition, more calls appends with AND.
at line 333
Selection
joinWhere($tableChain, $condition, ...$params)
Adds ON condition when joining specified table, more calls appends with AND.
at line 345
protected void
condition($condition, array $params, $tableChain = null)
Adds condition, more calls appends with AND.
at line 371
Selection
whereOr(array $parameters)
Adds where condition using the OR operator between parameters.
More calls appends with AND.
at line 403
Selection
order($columns, ...$params)
Adds order clause, more calls appends to the end.
at line 417
Selection
limit($limit, $offset = null)
Sets limit clause, more calls rewrite old values.
at line 431
Selection
page($page, $itemsPerPage, $numOfPages = null)
Sets offset using page number, more calls rewrite old values.
at line 448
Selection
group($columns, ...$params)
Sets group clause, more calls rewrite old value.
at line 461
Selection
having($having, ...$params)
Sets having clause, more calls rewrite old value.
at line 475
Selection
alias($tableChain, $alias)
Aliases table. Example ':book:book_tag.tag', 'tg'
at line 491
int
aggregation($function, $groupFunction = null)
Executes aggregation function.
at line 513
int
count($column = null)
Counts number of rows.
at line 528
int
min($column)
Returns minimum value from a column.
at line 539
int
max($column)
Returns maximum value from a column.
at line 550
int
sum($column)
Returns sum of values in a column.
at line 559
protected
execute()
No description
at line 605
protected ActiveRow
createRow(array $row)
No description
at line 614
Selection
createSelectionInstance($table = null)
No description
at line 623
protected GroupedSelection
createGroupedSelectionInstance($table, $column)
No description
at line 632
protected ResultSet
query($query)
No description
at line 638
protected
emptyResultSet($clearCache = true, $deleteRererencedCache = true)
No description
at line 660
protected
saveCacheState()
No description
at line 682
protected Selection
getRefTable($refPath)
Returns Selection parent for caching.
at line 691
protected
loadRefCache()
Loads refCache references
at line 701
protected string
getGeneralCacheKey()
Returns general cache key independent on query parameters or sql limit Used e.g. for previously accessed columns caching
at line 723
protected string
getSpecificCacheKey()
Returns object specific cache key dependent on query parameters Used e.g. for reference memory caching
at line 739
bool
accessColumn($key, $selectColumn = true)
internal |
No description
at line 795
removeAccessColumn($key)
internal |
No description
at line 807
bool
getDataRefreshed()
Returns if selection requeried for more columns.
at line 821
ActiveRow|int|bool
insert($data)
Inserts row in a table.
at line 902
int
update($data)
Updates all rows in result set.
Joins in UPDATE are supported only in MySQL
at line 926
int
delete()
Deletes all rows in result set.
at line 942
ActiveRow|null|false
getReferencedTable(ActiveRow $row, $table, $column = null)
Returns referenced row.
at line 991
GroupedSelection|null
getReferencingTable($table, $column, $active = null)
Returns referencing rows.
at line 1018
rewind()
No description
at line 1027
ActiveRow|bool
current()
No description
at line 1040
string|int
key()
No description
at line 1046
next()
No description
at line 1054
valid()
No description
at line 1069
void
offsetSet($key, $value)
Mimic row.
at line 1081
ActiveRow|null
offsetGet($key)
Returns specified row.
at line 1093
bool
offsetExists($key)
Tests if row exists.
at line 1105
void
offsetUnset($key)
Removes row from result set.