Namespaces

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

Classes

  • ActiveRow
  • GroupedSelection
  • Selection
  • Overview
  • Namespace
  • Class
  • Tree

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, ArrayAccess, Countable

Direct known subclasses

Nette\Database\Table\GroupedSelection
Namespace: Nette\Database\Table
Author: Jakub Vrana
Located at Database/Table/Selection.php
Methods summary
public
# __construct( string $table, Nette\Database\Connection $connection )

Parameters

$table
string
$connection
public
# __destruct( )

Saves data to cache and empty result.

Saves data to cache and empty result.

public Nette\Database\Connection
# getConnection( )

Returns

Nette\Database\Connection
public string
# getName( )

Returns

string
public string
# getPrimary( )

Returns

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

Returns row specified by primary key.

Returns row specified by primary key.

Parameters

$key
mixed

Returns

Nette\Database\Table\ActiveRow
or NULL if there is no such row
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
provides a fluent interface
public Nette\Database\Table\Selection
# find( mixed $key )

Selects by primary key.

Selects by primary key.

Parameters

$key
mixed

Returns

Nette\Database\Table\Selection
provides a fluent interface
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
provides a fluent interface
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
provides a fluent interface
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
provides a fluent interface
public Nette\Database\Table\Selection
# page( integer $page, integer $itemsPerPage )

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

Returns

Nette\Database\Table\Selection
provides a fluent interface
public Nette\Database\Table\Selection
# group( string $columns, string $having = '' )

Sets group clause, more calls rewrite old values.

Sets group clause, more calls rewrite old values.

Parameters

$columns
string
$having
string

Returns

Nette\Database\Table\Selection
provides a fluent interface
public string
# aggregation( string $function )

Executes aggregation function.

Executes aggregation function.

Parameters

$function
string

Returns

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

Counts number of rows.

Counts number of rows.

Parameters

$column
string

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
public string
# getSql( )

Returns SQL query.

Returns SQL query.

Returns

string
protected
# createJoins( $val, $inner = FALSE )
protected null
# execute( )

Executes built query.

Executes built query.

Returns

null
protected
# whereString( )
protected
# topString( )
protected
# tryDelimite( $s )
protected
# removeExtraTables( $expression )
protected
# query( $query )
public
# access( $key, $delete = FALSE )
public Nette\Database\Table\ActiveRow
# insert( mixed $data )

Inserts row in a table.

Inserts row in a table.

Parameters

$data
mixed
array($column => $value)|Traversable for single row insert or Selection|string for INSERT ... SELECT

Returns

Nette\Database\Table\ActiveRow
or FALSE in case of an error or number of affected rows for INSERT ... SELECT
public integer
# update( array|Traversable $data )

Updates all rows in result set.

Updates all rows in result set.

Parameters

$data
array|Traversable
($column => $value)

Returns

integer
number of affected rows or FALSE in case of an error
public integer
# delete( )

Deletes all rows in result set.

Deletes all rows in result set.

Returns

integer
number of affected rows or FALSE in case of an error
public Nette\Database\Table\ActiveRow
# getReferencedTable( string $table, string $column, boolean $checkReferenceNewKeys = FALSE )

Returns referenced row.

Returns referenced row.

Parameters

$table
string
$column
string
$checkReferenceNewKeys
boolean
checks if rows contains the same primary value relations

Returns

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

Returns referencing rows.

Returns referencing rows.

Parameters

$table
string
$column
string
$active

Returns

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

Implementation of

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

Returns

Nette\Database\Table\ActiveRow

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\ActiveRow $value )

Mimic row.

Mimic row.

Parameters

$key
string
row ID
$value
Nette\Database\Table\ActiveRow

Returns

null

Implementation of

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

Returns specified row.

Returns specified row.

Parameters

$key
string
row ID

Returns

Nette\Database\Table\ActiveRow
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
public Nette\Database\Table\ActiveRow
# fetch( )

Returns next row of result.

Returns next row of result.

Returns

Nette\Database\Table\ActiveRow
or FALSE if there is no row
public array
# fetchPairs( string $key, string $value = '' )

Returns all rows as associative array.

Returns all rows as associative array.

Parameters

$key
string
$value
string
column name used for an array value or an empty string for the whole row

Returns

array
Methods inherited from Nette\Object
__call(), __callStatic(), __get(), __isset(), __set(), __unset(), extensionMethod(), getReflection()
Properties summary
protected Nette\Database\Connection $connection
#
protected string $name
#

table name

table name

protected string $primary
#

primary key field name

primary key field name

protected array $rows
#

of [primary key => TableRow] readed from database

of [primary key => TableRow] readed from database

protected array $data
#

of [primary key => TableRow] modifiable

of [primary key => TableRow] modifiable

protected array $select array()
#

of column to select

of column to select

protected array $where array()
#

of where conditions

of where conditions

protected array $conditions array()
#

of where conditions for caching

of where conditions for caching

protected array $parameters array()
#

of parameters passed to where conditions

of parameters passed to where conditions

protected array $order array()
#

or columns to order by

or columns to order by

protected integer $limit NULL
#

number of rows to fetch

number of rows to fetch

protected integer $offset NULL
#

first row to fetch

first row to fetch

protected string $group ''
#

columns to grouping

columns to grouping

protected string $having ''
#

grouping condition

grouping condition

protected boolean $checkReferenceNewKeys FALSE
#

recheck referencing keys

recheck referencing keys

protected array $referenced array()
#

of referenced TableSelection

of referenced TableSelection

protected array $referencing array()
#

of [sql+parameters => [column => [key => TableRow]]] used by GroupedTableSelection

of [sql+parameters => [column => [key => TableRow]]] used by GroupedTableSelection

protected array $aggregation array()
#

of [conditions => [key => TableRow]] used by GroupedTableSelection

of [conditions => [key => TableRow]] used by GroupedTableSelection

protected array $accessed
#

of touched columns

of touched columns

protected array $prevAccessed
#

of earlier touched columns

of earlier touched columns

protected array $keys array()
#

of primary key values

of primary key values

protected string $delimitedName
#
protected string $delimitedPrimary
#
Nette Framework 2.0.0 API API documentation generated by ApiGen 2.7.0