Packages

  • 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

  • GroupedTableSelection
  • SqlBuilder
  • TableRow
  • TableSelection
  • Overview
  • Package
  • Class
  • Tree

Class TableSelection

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

Object
Extended by TableSelection implements Iterator, ArrayAccess, Countable

Direct known subclasses

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

Creates filtered table representation.

Creates filtered table representation.

Parameters

$table
string
database table name
$connection
Connection
public
# __destruct( )
public
# __clone( )
public Connection
# getConnection( )

Returns

Connection
public string
# getName( )

Returns

string
public string
# getPrimary( )

Returns

string
public string
# getSql( )

Returns

string
public TableRow
# get( mixed $key )

Returns row specified by primary key.

Returns row specified by primary key.

Parameters

$key
mixed
primary key

Returns

TableRow
or FALSE if there is no such row
public TableRow
# fetch( )

Returns next row of result.

Returns next row of result.

Returns

TableRow
or FALSE if there is no row
public array
# fetchPairs( string $key, string $value = NULL )

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 NULL for the whole row

Returns

array
public TableSelection
# 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

TableSelection
provides a fluent interface
public TableSelection
# find( mixed $key )

Selects by primary key.

Selects by primary key.

Parameters

$key
mixed

Returns

TableSelection
provides a fluent interface
public TableSelection
# 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

TableSelection
provides a fluent interface
public TableSelection
# 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

TableSelection
provides a fluent interface
public TableSelection
# 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

TableSelection
provides a fluent interface
public TableSelection
# 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

TableSelection
provides a fluent interface
public TableSelection
# group( string $columns, string $having = NULL )

Sets group clause, more calls rewrite old values.

Sets group clause, more calls rewrite old values.

Parameters

$columns
string
$having
string

Returns

TableSelection
provides a fluent interface
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 )
protected
# createSelectionInstance( $table = NULL )
protected
# createGroupedSelectionInstance( $table, $column )
protected
# query( $query )
protected
# emptyResultSet( )
protected
# saveCacheState( )
protected TableSelection
# getRefTable( & $refPath )

Returns Selection parent for caching

Returns Selection parent for caching

Returns

TableSelection
public TableRow
# 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

TableRow
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. 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 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 TableSelection
# getReferencedTable( string $table, string $column, boolean $checkReferenced = FALSE )

Returns referenced row.

Returns referenced row.

Parameters

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

Returns

TableSelection
or array() if the row does not exist
public GroupedTableSelection
# getReferencingTable( string $table, string $column, integer $active = NULL )

Returns referencing rows.

Returns referencing rows.

Parameters

$table
string
$column
string
$active
integer
primary key

Returns

GroupedTableSelection
public
# rewind( )

Implementation of

Iterator::rewind
public TableRow
# current( )

Returns

TableRow

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, TableRow $value )

Mimic row.

Mimic row.

Parameters

$key
string
row ID
$value
TableRow

Returns

null

Implementation of

ArrayAccess::offsetSet
public TableRow
# offsetGet( string $key )

Returns specified row.

Returns specified row.

Parameters

$key
string
row ID

Returns

TableRow
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 Object
__call(), __callStatic(), __get(), __isset(), __set(), __unset(), extensionMethod(), getReflection()
Properties summary
protected Connection $connection
#
protected SqlBuilder $sqlBuilder
#
protected string $name
#

table name

table name

protected string $primary
#

primary key field name

primary key field name

protected TableRow[] $rows
#

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

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

protected TableRow[] $data
#

modifiable data in [primary key => ActiveRow] format

modifiable data in [primary key => ActiveRow] format

protected TableSelection[] $referenced array()
#
protected array $referencing array()
#

of [sqlQuery-hash => grouped data]; used by GroupedSelection

of [sqlQuery-hash => grouped data]; used by GroupedSelection

protected GroupedTableSelection[] $referencingPrototype array()
#

cached array of GroupedSelection prototypes

cached array of GroupedSelection prototypes

protected array $aggregation array()
#

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

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

protected array $accessed
#

of touched columns

of touched columns

protected array $prevAccessed
#

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 boolean $checkReferenced FALSE
#

recheck referencing keys

recheck referencing keys

protected array $keys array()
#

of primary key values

of primary key values

Nette Framework 2.0.5 (for PHP 5.2, un-prefixed) API API documentation generated by ApiGen 2.7.0