Class NTableSelection
Filtered table representation. Selector is based on the great library NotORM http://www.notorm.com written by Jakub Vrana.
- NObject
-
NTableSelection implements Iterator, Traversable, ArrayAccess, Countable
Direct Known Subclasses
NGroupedTableSelection
public
|
#
__construct(
string
$table,
NConnection
$connection
)
Parameters$table string$connection 1 |
public
|
#
__destruct(
)
Saves data to cache and empty result. Saves data to cache and empty result. |
public
NTableRow
|
#
get(
mixed
$key
)
Returns row specified by primary key. Returns row specified by primary key. Parameters$key mixedReturnsNTableRow or NULL if there is no such row
|
public
NTableSelection
|
#
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"ReturnsNTableSelection provides a fluent interface
|
public
NTableSelection
|
#
find(
mixed
$key
)
Selects by primary key. Selects by primary key. Parameters$key mixedReturnsNTableSelection provides a fluent interface
|
public
NTableSelection
|
#
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 mixedReturnsNTableSelection provides a fluent interface
|
public
NTableSelection
|
#
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'ReturnsNTableSelection provides a fluent interface
|
public
NTableSelection
|
#
limit(
int
$limit,
int
$offset = NULL
)
Sets limit clause, more calls rewrite old values. Sets limit clause, more calls rewrite old values. Parameters$limit int$offset intReturnsNTableSelection provides a fluent interface
|
public
NTableSelection
|
#
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 stringReturnsNTableSelection provides a fluent interface
|
public
string
|
#
aggregation(
string
$function
)
Executes aggregation function. Executes aggregation function. Parameters$function string |
public
int
|
#
count(
string
$column = ''
)
Counts number of rows. |
public
int
|
#
min(
string
$column
)
Returns minimum value from a column. Returns minimum value from a column. Parameters$column string |
public
int
|
#
max(
string
$column
)
Returns maximum value from a column. Returns maximum value from a column. Parameters$column string |
public
int
|
#
sum(
string
$column
)
Returns sum of values in a column. Returns sum of values in a column. Parameters$column string |
public
string
|
#
getSql(
)
Returns SQL query. Returns SQL query. |
protected
|
#
createJoins(
$val,
$inner = false
)
|
protected
|
#
execute(
)
Executes built query. Executes built query. |
protected
|
#
whereString(
)
|
protected
|
#
topString(
)
|
protected
|
#
tryDelimite(
$s
)
|
protected
|
#
query(
$query
)
|
public
|
#
access(
$key,
$delete = false
)
|
public
NTableRow
|
#
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 TableSelection|string for INSERT ... SELECTReturnsNTableRow or FALSE in case of an error or number of affected rows for INSERT ... SELECT
|
public
int
|
#
update(
array
$data
)
Updates all rows in result set. Updates all rows in result set. Parameters$data array ($column => $value)Returnsint number of affected rows or FALSE in case of an error
|
public
int
|
#
delete(
)
Deletes all rows in result set. Deletes all rows in result set. Returnsint number of affected rows or FALSE in case of an error
|
public
NTableRow
|
#
getReferencedTable(
string
$name,
& $column = NULL
)
Returns referenced row. Returns referenced row. Parameters$name string$column ReturnsNTableRow or NULL if the row does not exist
|
public
NGroupedTableSelection
|
#
getReferencingTable(
string
$table
)
Returns referencing rows. Returns referencing rows. Parameters$table string table name |
public
|
#
rewind(
)
Implementation of |
public
NTableRow
|
#
current(
)
Implementation of |
public
string
|
#
key(
)
|
public
|
#
next(
)
Implementation of |
public
|
#
valid(
)
Implementation of |
public
|
#
offsetSet(
string
$key,
NTableRow
$value
)
Mimic row. |
public
NTableRow
|
#
offsetGet(
string
$key
)
Returns specified row. Returns specified row. Parameters$key string row IDReturnsNTableRow or NULL if there is no such row
Implementation of |
public
bool
|
#
offsetExists(
string
$key
)
Tests if row exists. |
public
|
#
offsetUnset(
string
$key
)
Removes row from result set. Removes row from result set. Parameters$key string row IDImplementation of |
public
NTableRow
|
#
fetch(
)
Returns next row of result. Returns next row of result. ReturnsNTableRow 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 |
Methods Inherited From NObject
getReflection(), __call(), __callStatic(), extensionMethod(), __get(), __set(), __isset(), __unset()
NConnection
|
$connection | NULL |
# |
string
|
$name | NULL |
table name # |
string
|
$primary | NULL |
primary key field name # |
protected
array
|
$rows | NULL |
of [primary key ⇒ TableRow] readed from database # |
protected
array
|
$data | NULL |
of [primary key ⇒ TableRow] modifiable # |
protected
array
|
$select | array (
) |
of column to select # |
protected
array
|
$where | array (
) |
of where conditions # |
protected
array
|
$conditions | array (
) |
of where conditions for caching # |
protected
array
|
$parameters | array (
) |
of parameters passed to where conditions # |
protected
array
|
$order | array (
) |
or columns to order by # |
protected
int
|
$limit | NULL |
number of rows to fetch # |
protected
int
|
$offset | NULL |
first row to fetch # |
protected
string
|
$group | '' |
columns to grouping # |
protected
string
|
$having | '' |
grouping condition # |
protected
array
|
$referenced | array (
) |
of referenced TableSelection # |
protected
array
|
$referencing | array (
) |
of [sql ⇒ [column ⇒ [key ⇒ TableRow]]] used by GroupedTableSelection # |
protected
array
|
$aggregation | array (
) |
of [sql ⇒ [key ⇒ TableRow]] used by GroupedTableSelection # |
protected
array
|
$accessed | NULL |
of touched columns # |
protected
array
|
$prevAccessed | NULL |
of earlier touched columns # |
protected
array
|
$keys | array (
) |
of primary key values # |
protected
string
|
$delimitedName | NULL |
# |
protected
string
|
$delimitedPrimary | NULL |
# |