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 Explorer | $explorer | ||
protected Explorer | $context | ||
protected Conventions | $conventions | ||
protected Cache | $cache | ||
protected SqlBuilder | $sqlBuilder | ||
protected string | $name | ||
protected string|string[]|null | $primary | ||
protected string|bool | $primarySequence | ||
protected ActiveRow[] | $rows | ||
protected ActiveRow[] | $data | ||
protected bool | $dataRefreshed | ||
protected mixed | $globalRefCache | ||
protected mixed | $refCache | ||
protected string|null | $generalCacheKey | ||
protected string|null | $specificCacheKey | ||
protected array | $aggregation | ||
protected array|false|null | $accessedColumns | ||
protected array|false|null | $previousAccessedColumns | ||
protected Selection|null | $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
Returns row specified by primary key.
Fetches single row object.
Fetches all rows as associative array.
Fetches all rows.
Fetches all rows and returns associative tree.
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 limit clause, more calls rewrite old values.
Sets offset using page number, more calls rewrite old values.
Aliases table. Example ':book:book_tag.tag', 'tg'
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 referenced row.
Returns referencing rows.
No description
No description
No description
No description
Returns specified row.
Tests if row exists.
Removes row from result set.
Details
at line 89
__construct(Explorer $explorer, Conventions $conventions, string $tableName, IStorage $cacheStorage = null)
Creates filtered table representation.
at line 108
__destruct()
at line 114
__clone()
at line 120
string
getName()
at line 129
string|string[]|null
getPrimary(bool $throw = true)
at line 138
string|null
getPrimarySequence()
at line 151
Selection
setPrimarySequence(string $sequence)
at line 158
string
getSql()
at line 169
array|bool
getPreviousAccessedColumns()
Loads cache of previous accessed columns and returns it.
at line 185
SqlBuilder
getSqlBuilder()
at line 198
ActiveRow|null
get(mixed $key)
Returns row specified by primary key.
at line 208
ActiveRow|null
fetch()
Fetches single row object.
at line 222
mixed
fetchField(string $column = null)
deprecated
deprecated
Fetches single field.
at line 242
array
fetchPairs(string|int $key = null, string|int $value = null)
Fetches all rows as associative array.
at line 252
array
fetchAll()
Fetches all rows.
at line 262
array
fetchAssoc(string $path)
Fetches all rows and returns associative tree.
at line 277
Selection
select($columns, ...$params)
Adds select clause, more calls appends to the end.
at line 290
Selection
wherePrimary(mixed $key)
Adds condition for primary key.
at line 315
Selection
where($condition, ...$params)
Adds where condition, more calls appends with AND.
at line 328
Selection
joinWhere(string $tableChain, string $condition, ...$params)
Adds ON condition when joining specified table, more calls appends with AND.
at line 339
protected void
condition($condition, array $params, $tableChain = null)
Adds condition, more calls appends with AND.
at line 365
Selection
whereOr(array $parameters)
Adds where condition using the OR operator between parameters.
More calls appends with AND.
at line 397
Selection
order(string $columns, ...$params)
Adds order clause, more calls appends to the end.
at line 409
Selection
limit(int|null $limit, int $offset = null)
Sets limit clause, more calls rewrite old values.
at line 421
Selection
page(int $page, int $itemsPerPage, $numOfPages = null)
Sets offset using page number, more calls rewrite old values.
at line 437
Selection
group(string $columns, ...$params)
Sets group clause, more calls rewrite old value.
at line 449
Selection
having(string $having, ...$params)
Sets having clause, more calls rewrite old value.
at line 461
Selection
alias(string $tableChain, string $alias)
Aliases table. Example ':book:book_tag.tag', 'tg'
at line 476
mixed
aggregation(string $function)
Executes aggregation function.
at line 491
int
count(string $column = null)
Counts number of rows.
at line 505
mixed
min(string $column)
Returns minimum value from a column.
at line 515
mixed
max(string $column)
Returns maximum value from a column.
at line 525
mixed
sum(string $column)
Returns sum of values in a column.
at line 534
protected void
execute()
at line 577
protected ActiveRow
createRow(array $row)
at line 583
Selection
createSelectionInstance(string $table = null)
at line 589
protected GroupedSelection
createGroupedSelectionInstance(string $table, string $column)
at line 595
protected ResultSet
query(string $query)
at line 601
protected void
emptyResultSet(bool $clearCache = true, bool $deleteRererencedCache = true)
at line 623
protected void
saveCacheState()
at line 652
protected Selection
getRefTable($refPath)
Returns Selection parent for caching.
at line 661
protected void
loadRefCache()
Loads refCache references
at line 670
protected string
getGeneralCacheKey()
Returns general cache key independent on query parameters or sql limit Used e.g. for previously accessed columns caching
at line 693
protected string
getSpecificCacheKey()
Returns object specific cache key dependent on query parameters Used e.g. for reference memory caching
at line 708
bool
accessColumn(string|null $key, bool $selectColumn = true)
at line 773
void
removeAccessColumn(string $key)
at line 784
bool
getDataRefreshed()
Returns if selection requeried for more columns.
at line 798
ActiveRow|int|bool
insert(iterable $data)
Inserts row in a table.
at line 878
int
update(iterable $data)
Updates all rows in result set.
Joins in UPDATE are supported only in MySQL
at line 902
int
delete()
Deletes all rows in result set.
at line 915
ActiveRow|false|null
getReferencedTable(ActiveRow $row, string|null $table, string $column = null)
Returns referenced row.
at line 961
GroupedSelection|null
getReferencingTable(string $table, string $column = null, $active = null)
Returns referencing rows.
at line 988
void
rewind()
at line 997
ActiveRow|false
current()
at line 1008
string|int
key()
at line 1014
void
next()
at line 1022
bool
valid()
at line 1036
void
offsetSet(string $key, ActiveRow $value)
Mimic row.
at line 1047
ActiveRow|null
offsetGet(string $key)
Returns specified row.
at line 1058
bool
offsetExists(string $key)
Tests if row exists.
at line 1069
void
offsetUnset(string $key)
Removes row from result set.