PHP Class Nette\Database\Table\Selection

Selection is based on the great library NotORM http://www.notorm.com written by Jakub Vrana.
Author: Jakub Vrana
Author: Jan Skrasek
Inheritance: extends Nette\Object, implements Iterator, implements ArrayAccess, implements Countable
Afficher le fichier Open project: nette/database Class Usage Examples

Protected Properties

Свойство Type Description
$accessedColumns of touched columns
$aggregation of [conditions => [key => IRow]]; used by GroupedSelection
$cache Nette\Caching\Cache
$context Nette\Database\Context
$conventions Nette\Database\IConventions
$data modifiable data in [primary key => IRow] format
$dataRefreshed boolean
$generalCacheKey string
$globalRefCache cache array of Selection and GroupedSelection prototypes
$keys of primary key values
$name table name
$observeCache should instance observe accessed columns caching
$previousAccessedColumns of earlier touched columns
$primary primary key field name
$primarySequence primary column sequence name, FALSE for autodetection
$refCache mixed
$rows data read from database in [primary key => IRow] format
$specificCacheKey string
$sqlBuilder SqlBuilder

Méthodes publiques

Méthode Description
__clone ( )
__construct ( Context $context, Nette\Database\IConventions $conventions, $tableName, Nette\Caching\IStorage $cacheStorage = NULL ) Creates filtered table representation.
__destruct ( )
accessColumn ( $key, $selectColumn = TRUE ) : boolean
aggregation ( $function ) : string Executes aggregation function.
alias ( $tableChain, $alias ) : self Aliases table. Example ':book:book_tag.tag', 'tg'
count ( $column = NULL ) : integer Counts number of rows.
createSelectionInstance ( $table = NULL )
current ( ) : Nette\Database\Table\IRow
delete ( ) : integer Deletes all rows in result set.
fetch ( )
fetchAll ( )
fetchAssoc ( $path )
fetchField ( $column = NULL ) : mixed | FALSE Fetches single field.
fetchPairs ( $key = NULL, $value = NULL )
get ( $key ) : Nette\Database\Table\IRow Returns row specified by primary key.
getDataRefreshed ( ) : boolean Returns if selection requeried for more columns.
getName ( ) : string
getPreviousAccessedColumns ( ) : array | false Loads cache of previous accessed columns and returns it.
getPrimary ( $need = TRUE ) : string | array | null
getPrimarySequence ( ) : string
getReferencedTable ( ActiveRow $row, $table, $column = NULL ) : ActiveRow | null | FALSE Returns referenced row.
getReferencingTable ( $table, $column, $active = NULL ) : GroupedSelection Returns referencing rows.
getSql ( ) : string
getSqlBuilder ( ) : SqlBuilder
group ( $columns, $params ) : self Sets group clause, more calls rewrite old value.
having ( $having, $params ) : self Sets having clause, more calls rewrite old value.
insert ( $data ) : Nette\Database\Table\IRow | integer | boolean Inserts row in a table.
joinWhere ( $tableChain, $condition, $params ) : self Adds ON condition when joining specified table, more calls appends with AND.
key ( ) : string
limit ( $limit, $offset = NULL ) : self Sets limit clause, more calls rewrite old values.
max ( $column ) : integer Returns maximum value from a column.
min ( $column ) : integer Returns minimum value from a column.
next ( )
offsetExists ( $key ) : boolean Tests if row exists.
offsetGet ( $key ) : Nette\Database\Table\IRow Returns specified row.
offsetSet ( $key, $value ) : null Mimic row.
offsetUnset ( $key ) : null Removes row from result set.
order ( $columns, $params ) : self Adds order clause, more calls appends to the end.
page ( $page, $itemsPerPage, &$numOfPages = NULL ) : self Sets offset using page number, more calls rewrite old values.
removeAccessColumn ( $key )
rewind ( ) ******************* interface Iterator ****************d*g*
select ( $columns, $params ) : self Adds select clause, more calls appends to the end.
setPrimarySequence ( $sequence ) : self
sum ( $column ) : integer Returns sum of values in a column.
update ( $data ) : integer Updates all rows in result set.
valid ( )
where ( $condition, $params ) : self Adds where condition, more calls appends with AND.
whereOr ( array $parameters ) : self Adds where condition using the OR operator between parameters.
wherePrimary ( $key ) : self Adds condition for primary key.

Méthodes protégées

Méthode Description
condition ( $condition, array $params, $tableChain = NULL ) : void Adds condition, more calls appends with AND.
createGroupedSelectionInstance ( $table, $column )
createRow ( array $row )
emptyResultSet ( $clearCache = TRUE, $deleteRererencedCache = TRUE )
execute ( ) ******************* internal ****************d*g*
getGeneralCacheKey ( ) : string Returns general cache key independent on query parameters or sql limit Used e.g. for previously accessed columns caching
getRefTable ( &$refPath ) : self Returns Selection parent for caching.
getSpecificCacheKey ( ) : string Returns object specific cache key dependent on query parameters Used e.g. for reference memory caching
loadRefCache ( ) Loads refCache references
query ( $query )
saveCacheState ( )

Method Details

__clone() public méthode

public __clone ( )

__construct() public méthode

Creates filtered table representation.
public __construct ( Context $context, Nette\Database\IConventions $conventions, $tableName, Nette\Caching\IStorage $cacheStorage = NULL )
$context Nette\Database\Context
$conventions Nette\Database\IConventions
$cacheStorage Nette\Caching\IStorage

__destruct() public méthode

public __destruct ( )

accessColumn() public méthode

public accessColumn ( $key, $selectColumn = TRUE ) : boolean
Résultat boolean if selection requeried for more columns.

aggregation() public méthode

Executes aggregation function.
public aggregation ( $function ) : string
Résultat string

alias() public méthode

Aliases table. Example ':book:book_tag.tag', 'tg'
public alias ( $tableChain, $alias ) : self
Résultat self

condition() protected méthode

Adds condition, more calls appends with AND.
protected condition ( $condition, array $params, $tableChain = NULL ) : void
$params array
Résultat void

count() public méthode

Counts number of rows.
public count ( $column = NULL ) : integer
Résultat integer

createGroupedSelectionInstance() protected méthode

protected createGroupedSelectionInstance ( $table, $column )

createRow() protected méthode

protected createRow ( array $row )
$row array

createSelectionInstance() public méthode

public createSelectionInstance ( $table = NULL )

current() public méthode

public current ( ) : Nette\Database\Table\IRow
Résultat Nette\Database\Table\IRow

delete() public méthode

Deletes all rows in result set.
public delete ( ) : integer
Résultat integer number of affected rows

emptyResultSet() protected méthode

protected emptyResultSet ( $clearCache = TRUE, $deleteRererencedCache = TRUE )

execute() protected méthode

******************* internal ****************d*g*
protected execute ( )

fetch() public méthode

public fetch ( )

fetchAll() public méthode

public fetchAll ( )

fetchAssoc() public méthode

public fetchAssoc ( $path )

fetchField() public méthode

Fetches single field.
public fetchField ( $column = NULL ) : mixed | FALSE
Résultat mixed | FALSE

fetchPairs() public méthode

public fetchPairs ( $key = NULL, $value = NULL )

get() public méthode

Returns row specified by primary key.
public get ( $key ) : Nette\Database\Table\IRow
Résultat Nette\Database\Table\IRow or FALSE if there is no such row

getDataRefreshed() public méthode

Returns if selection requeried for more columns.
public getDataRefreshed ( ) : boolean
Résultat boolean

getGeneralCacheKey() protected méthode

Returns general cache key independent on query parameters or sql limit Used e.g. for previously accessed columns caching
protected getGeneralCacheKey ( ) : string
Résultat string

getName() public méthode

public getName ( ) : string
Résultat string

getPreviousAccessedColumns() public méthode

Loads cache of previous accessed columns and returns it.
public getPreviousAccessedColumns ( ) : array | false
Résultat array | false

getPrimary() public méthode

public getPrimary ( $need = TRUE ) : string | array | null
Résultat string | array | null

getPrimarySequence() public méthode

public getPrimarySequence ( ) : string
Résultat string

getRefTable() protected méthode

Returns Selection parent for caching.
protected getRefTable ( &$refPath ) : self
Résultat self

getReferencedTable() public méthode

Returns referenced row.
public getReferencedTable ( ActiveRow $row, $table, $column = NULL ) : ActiveRow | null | FALSE
$row ActiveRow
Résultat ActiveRow | null | FALSE NULL if the row does not exist, FALSE if the relationship does not exist

getReferencingTable() public méthode

Returns referencing rows.
public getReferencingTable ( $table, $column, $active = NULL ) : GroupedSelection
Résultat GroupedSelection

getSpecificCacheKey() protected méthode

Returns object specific cache key dependent on query parameters Used e.g. for reference memory caching
protected getSpecificCacheKey ( ) : string
Résultat string

getSql() public méthode

public getSql ( ) : string
Résultat string

getSqlBuilder() public méthode

public getSqlBuilder ( ) : SqlBuilder
Résultat SqlBuilder

group() public méthode

Sets group clause, more calls rewrite old value.
public group ( $columns, $params ) : self
Résultat self

having() public méthode

Sets having clause, more calls rewrite old value.
public having ( $having, $params ) : self
Résultat self

insert() public méthode

Inserts row in a table.
public insert ( $data ) : Nette\Database\Table\IRow | integer | boolean
Résultat Nette\Database\Table\IRow | integer | boolean Returns IRow or number of affected rows for Selection or table without primary key

joinWhere() public méthode

Adds ON condition when joining specified table, more calls appends with AND.
public joinWhere ( $tableChain, $condition, $params ) : self
Résultat self

key() public méthode

public key ( ) : string
Résultat string row ID

limit() public méthode

Sets limit clause, more calls rewrite old values.
public limit ( $limit, $offset = NULL ) : self
Résultat self

loadRefCache() protected méthode

Loads refCache references
protected loadRefCache ( )

max() public méthode

Returns maximum value from a column.
public max ( $column ) : integer
Résultat integer

min() public méthode

Returns minimum value from a column.
public min ( $column ) : integer
Résultat integer

next() public méthode

public next ( )

offsetExists() public méthode

Tests if row exists.
public offsetExists ( $key ) : boolean
Résultat boolean

offsetGet() public méthode

Returns specified row.
public offsetGet ( $key ) : Nette\Database\Table\IRow
Résultat Nette\Database\Table\IRow or NULL if there is no such row

offsetSet() public méthode

Mimic row.
public offsetSet ( $key, $value ) : null
Résultat null

offsetUnset() public méthode

Removes row from result set.
public offsetUnset ( $key ) : null
Résultat null

order() public méthode

Adds order clause, more calls appends to the end.
public order ( $columns, $params ) : self
Résultat self

page() public méthode

Sets offset using page number, more calls rewrite old values.
public page ( $page, $itemsPerPage, &$numOfPages = NULL ) : self
Résultat self

query() protected méthode

protected query ( $query )

removeAccessColumn() public méthode

public removeAccessColumn ( $key )

rewind() public méthode

******************* interface Iterator ****************d*g*
public rewind ( )

saveCacheState() protected méthode

protected saveCacheState ( )

select() public méthode

Adds select clause, more calls appends to the end.
public select ( $columns, $params ) : self
Résultat self

setPrimarySequence() public méthode

public setPrimarySequence ( $sequence ) : self
Résultat self

sum() public méthode

Returns sum of values in a column.
public sum ( $column ) : integer
Résultat integer

update() public méthode

Joins in UPDATE are supported only in MySQL
public update ( $data ) : integer
Résultat integer number of affected rows

valid() public méthode

public valid ( )

where() public méthode

Adds where condition, more calls appends with AND.
public where ( $condition, $params ) : self
Résultat self

whereOr() public méthode

More calls appends with AND.
public whereOr ( array $parameters ) : self
$parameters array
Résultat self

wherePrimary() public méthode

Adds condition for primary key.
public wherePrimary ( $key ) : self
Résultat self

Property Details

$accessedColumns protected_oe property

of touched columns
protected $accessedColumns

$aggregation protected_oe property

of [conditions => [key => IRow]]; used by GroupedSelection
protected $aggregation

$cache protected_oe property

protected Cache,Nette\Caching $cache
Résultat Nette\Caching\Cache

$context protected_oe property

protected Context,Nette\Database $context
Résultat Nette\Database\Context

$conventions protected_oe property

protected IConventions,Nette\Database $conventions
Résultat Nette\Database\IConventions

$data protected_oe property

modifiable data in [primary key => IRow] format
protected $data

$dataRefreshed protected_oe property

protected bool $dataRefreshed
Résultat boolean

$generalCacheKey protected_oe property

protected string $generalCacheKey
Résultat string

$globalRefCache protected_oe property

cache array of Selection and GroupedSelection prototypes
protected $globalRefCache

$keys protected_oe property

of primary key values
protected $keys

$name protected_oe property

table name
protected $name

$observeCache protected_oe property

should instance observe accessed columns caching
protected $observeCache

$previousAccessedColumns protected_oe property

of earlier touched columns
protected $previousAccessedColumns

$primary protected_oe property

primary key field name
protected $primary

$primarySequence protected_oe property

primary column sequence name, FALSE for autodetection
protected $primarySequence

$refCache protected_oe property

protected mixed $refCache
Résultat mixed

$rows protected_oe property

data read from database in [primary key => IRow] format
protected $rows

$specificCacheKey protected_oe property

protected string $specificCacheKey
Résultat string

$sqlBuilder protected_oe property

protected SqlBuilder,Nette\Database\Table $sqlBuilder
Résultat SqlBuilder