Namespaces

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Diagnostics
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
      • Diagnostics
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • PhpGenerator
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
  • NetteModule
  • none

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
Author: Jakub Vrana
Author: Jan Skrasek
Located at Database/Table/Selection.php
Methods summary
public
# __construct( Nette\Database\Connection $connection, string $table, Nette\Database\IReflection $reflection, Nette\Caching\IStorage $cacheStorage = NULL )

Creates filtered table representation.

Creates filtered table representation.

Parameters

$connection
Nette\Database\Connection
$table
string
database table name
$reflection
$cacheStorage
public
# __destruct( )
public
# __clone( )
public Nette\Database\Connection
# getConnection( )

Returns

Nette\Database\Connection
public Nette\Database\IReflection
# getDatabaseReflection( )

Returns

Nette\Database\IReflection
public string
# getName( )

Returns

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

Parameters

$need
boolean

Returns

string|array
public string
# getPrimarySequence( )

Returns

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

Parameters

$sequence
string

Returns

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

Returns

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

Returns row specified by primary key.

Returns row specified by primary key.

Parameters

$key
mixed
primary 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 array
# fetchPairs( string $key = NULL, string $value = NULL )

Parameters

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

Returns

array

InheritDoc

Implementation of

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

Returns

Nette\Database\Table\IRow[]

InheritDoc

Implementation of

Nette\Database\IRowContainer::fetchAll()
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
string
for example "column, MD5(column) AS column_md5"

Returns

Nette\Database\Table\Selection
public
# find( $key )

Deprecated

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

Adds condition for primary key.

Adds condition for primary key.

Parameters

$key
mixed

Returns

Nette\Database\Table\Selection
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
string
condition possibly containing ?
$parameters
mixed

Returns

Nette\Database\Table\Selection
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
string
for example 'column1, column2 DESC'

Returns

Nette\Database\Table\Selection
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
integer
$offset
integer

Returns

Nette\Database\Table\Selection
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
integer
$itemsPerPage
integer
$numOfPages

Returns

Nette\Database\Table\Selection
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
string

Returns

Nette\Database\Table\Selection
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
string

Returns

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

Executes aggregation function.

Executes aggregation function.

Parameters

$function
string
select call in "FUNCTION(column)" format

Returns

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

Counts number of rows.

Counts number of rows.

Parameters

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

Returns

integer

Implementation of

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

Returns minimum value from a column.

Returns minimum value from a column.

Parameters

$column
string

Returns

integer
public integer
# max( string $column )

Returns maximum value from a column.

Returns maximum value from a column.

Parameters

$column
string

Returns

integer
public integer
# sum( string $column )

Returns sum of values in a column.

Returns sum of values in a column.

Parameters

$column
string

Returns

integer
protected
# execute( )
protected
# createRow( array $row )
public
# createSelectionInstance( $table = NULL )
protected
# createGroupedSelectionInstance( $table, $column )
protected
# query( $query )
protected
# emptyResultSet( $saveCache = 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
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
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
public boolean
# getDataRefreshed( )

Returns if selection requeried for more columns.

Returns if selection requeried for more columns.

Returns

boolean
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
array|Traversable|Nette\Database\Table\Selection
array($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
array|Traversable
($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\Selection
# getReferencedTable( string $table, string $column, mixed $checkPrimaryKey )

Returns referenced row.

Returns referenced row.

Parameters

$table
string
$column
string
$checkPrimaryKey
mixed
primary key to check for $table and $column references

Returns

Nette\Database\Table\Selection
or array() if the row does not exist
public Nette\Database\Table\GroupedSelection
# getReferencingTable( string $table, string $column, integer $active = NULL )

Returns referencing rows.

Returns referencing rows.

Parameters

$table
string
$column
string
$active
integer
primary key

Returns

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

Implementation of

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

Returns

Nette\Database\Table\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
string
row ID
$value
Nette\Database\Table\IRow

Returns

null

Implementation of

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

Returns specified row.

Returns specified row.

Parameters

$key
string
row 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
string
row ID

Returns

boolean

Implementation of

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

Removes row from result set.

Removes row from result set.

Parameters

$key
string
row ID

Returns

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\Connection $connection
#
protected Nette\Database\IReflection $reflection
#
protected Nette\Caching\Cache $cache
#
protected Nette\Database\Table\SqlBuilder $sqlBuilder
#
protected string $name
#

table name

table name

protected string $primary
#

primary key field name

primary key field name

protected string|boolean $primarySequence FALSE
#

primary column sequence name, FALSE for autodetection

primary column sequence name, FALSE for autodetection

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 string $specificCacheKey
#
protected array $aggregation array()
#

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

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

protected array $accessedColumns
#

of touched columns

of touched columns

protected array $previousAccessedColumns
#

of earlier touched columns

of earlier touched columns

protected boolean $observeCache FALSE
#

should instance observe accessed columns caching

should instance observe accessed columns caching

protected array $keys array()
#

of primary key values

of primary key values

Magic properties summary
public read-only string $sql
#
Magic properties inherited from Nette\Object
$reflection
Nette 2.1 API documentation generated by ApiGen 2.8.0