Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Utils
  • none
  • Tracy
    • Bridges
      • Nette

Classes

  • ActiveRow
  • GroupedSelection
  • Selection
  • SqlBuilder

Interfaces

  • IRow
  • IRowContainer
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage

Class Selection

Filtered table representation. Selection is based on the great library NotORM http://www.notorm.com written by Jakub Vrana.

Nette\Object
Extended by Nette\Database\Table\Selection implements Iterator, Nette\Database\Table\IRowContainer, ArrayAccess, Countable

Direct known subclasses

Nette\Database\Table\GroupedSelection
Namespace: Nette\Database\Table
Located at Database/Table/Selection.php
Methods summary
public
# __construct( Nette\Database\Context $context, Nette\Database\IConventions $conventions, string $tableName, Nette\Caching\IStorage $cacheStorage = NULL )

Creates filtered table representation.

Creates filtered table representation.

Parameters

$context
$conventions
$tableName
name
$cacheStorage
public
# __destruct( )
public
# __clone( )
public
# getConnection( )

Deprecated

public
# getDatabaseReflection( )

Deprecated

public string
# getName( )

Returns

string
string
public string|array|null
# getPrimary( boolean $need = TRUE )

Parameters

$need

Returns

string|array|null
string|array|NULL
public string
# getPrimarySequence( )

Returns

string
string
public Nette\Database\Table\Selection
# setPrimarySequence( string $sequence )

Parameters

$sequence

Returns

Nette\Database\Table\Selection
self
public string
# getSql( )

Returns

string
string
public Nette\Database\Table\IRow
# get( mixed $key )

Returns row specified by primary key.

Returns row specified by primary key.

Parameters

$key
key

Returns

Nette\Database\Table\IRow
or FALSE if there is no such row
public Nette\Database\Table\IRow|boolean
# fetch( )

Returns

Nette\Database\Table\IRow|boolean
if there is no row

InheritDoc

Implementation of

Nette\Database\IRowContainer::fetch()
public mixed|false
# fetchField( string|null $column = NULL )

Fetches single field.

Fetches single field.

Parameters

$column

Returns

mixed|false
mixed|FALSE
public array
# fetchPairs( string $key = NULL, string $value = NULL )

Parameters

$key
name used for an array key or NULL for numeric index
$value
name used for an array value or NULL for the whole row

Returns

array
array

InheritDoc

Implementation of

Nette\Database\IRowContainer::fetchPairs()
public Nette\Database\Table\IRow[]
# fetchAll( )

Returns

Nette\Database\Table\IRow[]
IRow[]

InheritDoc

Implementation of

Nette\Database\IRowContainer::fetchAll()
public array
# fetchAssoc( string $path )

Parameters

$path
descriptor

Returns

array
array

InheritDoc

Implementation of

Nette\Database\IRowContainer::fetchAssoc()
public Nette\Database\Table\Selection
# select( string $columns )

Adds select clause, more calls appends to the end.

Adds select clause, more calls appends to the end.

Parameters

$columns
example "column, MD5(column) AS column_md5"

Returns

Nette\Database\Table\Selection
self
public Nette\Database\Table\Selection
# wherePrimary( mixed $key )

Adds condition for primary key.

Adds condition for primary key.

Parameters

$key

Returns

Nette\Database\Table\Selection
self
public Nette\Database\Table\Selection
# where( string $condition, mixed $parameters = array() )

Adds where condition, more calls appends with AND.

Adds where condition, more calls appends with AND.

Parameters

$condition
possibly containing ?
$parameters

Returns

Nette\Database\Table\Selection
self
public Nette\Database\Table\Selection
# order( string $columns )

Adds order clause, more calls appends to the end.

Adds order clause, more calls appends to the end.

Parameters

$columns
example 'column1, column2 DESC'

Returns

Nette\Database\Table\Selection
self
public Nette\Database\Table\Selection
# limit( integer $limit, integer $offset = NULL )

Sets limit clause, more calls rewrite old values.

Sets limit clause, more calls rewrite old values.

Parameters

$limit
$offset

Returns

Nette\Database\Table\Selection
self
public Nette\Database\Table\Selection
# page( integer $page, integer $itemsPerPage, & $numOfPages = NULL )

Sets offset using page number, more calls rewrite old values.

Sets offset using page number, more calls rewrite old values.

Parameters

$page
$itemsPerPage
$numOfPages

Returns

Nette\Database\Table\Selection
self
public Nette\Database\Table\Selection
# group( string $columns )

Sets group clause, more calls rewrite old value.

Sets group clause, more calls rewrite old value.

Parameters

$columns

Returns

Nette\Database\Table\Selection
self
public Nette\Database\Table\Selection
# having( string $having )

Sets having clause, more calls rewrite old value.

Sets having clause, more calls rewrite old value.

Parameters

$having

Returns

Nette\Database\Table\Selection
self
public string
# aggregation( string $function )

Executes aggregation function.

Executes aggregation function.

Parameters

$function
call in "FUNCTION(column)" format

Returns

string
string
public integer
# count( string $column = NULL )

Counts number of rows.

Counts number of rows.

Parameters

$column
it is not provided returns count of result rows, otherwise runs new sql counting query

Returns

integer
int

Implementation of

Countable::count()
public integer
# min( string $column )

Returns minimum value from a column.

Returns minimum value from a column.

Parameters

$column

Returns

integer
int
public integer
# max( string $column )

Returns maximum value from a column.

Returns maximum value from a column.

Parameters

$column

Returns

integer
int
public integer
# sum( string $column )

Returns sum of values in a column.

Returns sum of values in a column.

Parameters

$column

Returns

integer
int
protected
# execute( )
protected
# createRow( array $row )
public
# createSelectionInstance( $table = NULL )
protected
# createGroupedSelectionInstance( $table, $column )
protected
# query( $query )
protected
# emptyResultSet( $saveCache = TRUE, $deleteRererencedCache = TRUE )
protected
# saveCacheState( )
protected Nette\Database\Table\Selection
# getRefTable( & $refPath )

Returns Selection parent for caching.

Returns Selection parent for caching.

Returns

Nette\Database\Table\Selection
Selection
protected
# loadRefCache( )

Loads refCache references

Loads refCache references

protected string
# getGeneralCacheKey( )

Returns general cache key independent on query parameters or sql limit Used e.g. for previously accessed columns caching

Returns general cache key independent on query parameters or sql limit Used e.g. for previously accessed columns caching

Returns

string
string
protected string
# getSpecificCacheKey( )

Returns object specific cache key dependent on query parameters Used e.g. for reference memory caching

Returns object specific cache key dependent on query parameters Used e.g. for reference memory caching

Returns

string
string
public boolean
# getDataRefreshed( )

Returns if selection requeried for more columns.

Returns if selection requeried for more columns.

Returns

boolean
bool
public Nette\Database\Table\IRow|integer|boolean
# insert( array|Traversable|Nette\Database\Table\Selection $data )

Inserts row in a table.

Inserts row in a table.

Parameters

$data
$column => $value)|\Traversable|Selection for INSERT ... SELECT

Returns

Nette\Database\Table\IRow|integer|boolean
Returns IRow or number of affected rows for Selection or table without primary key
public integer
# update( array|Traversable $data )

Updates all rows in result set. Joins in UPDATE are supported only in MySQL

Updates all rows in result set. Joins in UPDATE are supported only in MySQL

Parameters

$data
$column => $value)

Returns

integer
number of affected rows
public integer
# delete( )

Deletes all rows in result set.

Deletes all rows in result set.

Returns

integer
number of affected rows
public Nette\Database\Table\ActiveRow|null|false
# getReferencedTable( Nette\Database\Table\ActiveRow $row, string $table, string|null $column = NULL )

Returns referenced row.

Returns referenced row.

Parameters

$row
$table
$column

Returns

Nette\Database\Table\ActiveRow|null|false
NULL if the row does not exist, FALSE if the relationship does not exist
public Nette\Database\Table\GroupedSelection
# getReferencingTable( string $table, string $column, integer $active = NULL )

Returns referencing rows.

Returns referencing rows.

Parameters

$table
$column
$active
key

Returns

Nette\Database\Table\GroupedSelection
GroupedSelection
public
# rewind( )

Implementation of

Iterator::rewind()
public Nette\Database\Table\IRow
# current( )

Returns

Nette\Database\Table\IRow
IRow

Implementation of

Iterator::current()
public string
# key( )

Returns

string
row ID

Implementation of

Iterator::key()
public
# next( )

Implementation of

Iterator::next()
public
# valid( )

Implementation of

Iterator::valid()
public null
# offsetSet( string $key, Nette\Database\Table\IRow $value )

Mimic row.

Mimic row.

Parameters

$key
ID
$value

Returns

null
NULL

Implementation of

ArrayAccess::offsetSet()
public Nette\Database\Table\IRow
# offsetGet( string $key )

Returns specified row.

Returns specified row.

Parameters

$key
ID

Returns

Nette\Database\Table\IRow
or NULL if there is no such row

Implementation of

ArrayAccess::offsetGet()
public boolean
# offsetExists( string $key )

Tests if row exists.

Tests if row exists.

Parameters

$key
ID

Returns

boolean
bool

Implementation of

ArrayAccess::offsetExists()
public null
# offsetUnset( string $key )

Removes row from result set.

Removes row from result set.

Parameters

$key
ID

Returns

null
NULL

Implementation of

ArrayAccess::offsetUnset()
Methods inherited from Nette\Object
__call(), __callStatic(), __get(), __isset(), __set(), __unset(), extensionMethod(), getReflection()
Magic methods inherited from Nette\Database\Table\IRowContainer
fetch()
Properties summary
protected Nette\Database\Context $context
#
protected Nette\Database\IConventions $conventions
#
protected Nette\Caching\Cache $cache
#
protected Nette\Database\Table\SqlBuilder $sqlBuilder
#
protected string $name

table name

table name

#
protected string|array|null $primary

primary key field name

primary key field name

#
protected string|boolean $primarySequence

primary column sequence name, FALSE for autodetection

primary column sequence name, FALSE for autodetection

#FALSE
protected Nette\Database\Table\IRow[] $rows

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

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

#
protected Nette\Database\Table\IRow[] $data

modifiable data in [primary key => IRow] format

modifiable data in [primary key => IRow] format

#
protected boolean $dataRefreshed
#FALSE
protected mixed $globalRefCache

cache array of Selection and GroupedSelection prototypes

cache array of Selection and GroupedSelection prototypes

#
protected mixed $refCache
#
protected string $generalCacheKey
#
protected array $generalCacheTraceKey
#
protected string $specificCacheKey
#
protected array $aggregation

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

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

#array()
protected array $accessedColumns

of touched columns

of touched columns

#
protected array $previousAccessedColumns

of earlier touched columns

of earlier touched columns

#
protected boolean $observeCache

should instance observe accessed columns caching

should instance observe accessed columns caching

#FALSE
protected array $keys

of primary key values

of primary key values

#array()
Magic properties summary
public read-only string $sql
Magic properties inherited from Nette\Object
$reflection
Nette 2.3-20161221 API API documentation generated by ApiGen 2.8.0