PHP Класс Prado\Data\Common\TDbCommandBuilder

С версии: 3.1
Наследование: extends Prado\TComponent
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( $connection = null, $tableInfo = null )
applyCriterias ( $sql, $parameters = [], $ordering = [], $limit, $offset )
applyLimitOffset ( $sql, $limit, $offset ) : string Alters the sql to apply $limit and $offset. Default implementation is applicable for PostgreSQL, MySQL and SQLite.
applyOrdering ( $sql, $ordering ) : string
bindArrayValues ( $command, $values )
bindColumnValues ( $command, $values ) Bind the name-value pairs of $values where the array keys correspond to column names.
createCommand ( $sql ) : TDbCommand
createCountCommand ( $where = '1=1', $parameters = [], $ordering = [], $limit, $offset ) : TDbCommand Creates a count(*) command for the table described in {@link setTableInfo TableInfo}.
createDeleteCommand ( $where, $parameters = [] ) : TDbCommand Creates a delete command for the table described in {@link setTableInfo TableInfo}.
createFindCommand ( $where = '1=1', $parameters = [], $ordering = [], $limit, $offset, $select = '*' ) : TDbCommand Appends the $where condition to the string "SELECT * FROM tableName WHERE ".
createInsertCommand ( $data ) : TDbCommand Creates an insert command for the table described in {@link setTableInfo TableInfo} for the given data.
createUpdateCommand ( $data, $where, $parameters = [] ) : TDbCommand Creates an update command for the table described in {@link setTableInfo TableInfo} for the given data.
getDbConnection ( ) : TDbConnection
getLastInsertID ( ) : mixed Iterate through all the columns and returns the last insert id of the first column that has a sequence or serial.
getPdoType ( $value ) : integer
getSearchExpression ( $fields, $keywords ) : string Computes the SQL condition for search a set of column using regular expression (or LIKE, depending on database implementation) to match a string of keywords (default matches all keywords).
getSelectFieldList ( $data = '*' ) : array Different behavior depends on type of passed data string usage without modification
getTableInfo ( )
setDbConnection ( $value )
setTableInfo ( $value )

Защищенные методы

Метод Описание
getColumnBindings ( $values, $position = false ) : string Create a name-value or position-value if $position=true binding strings.
getInsertFieldBindings ( $values ) : array Returns a list of insert field name and a list of binding names.
getSearchCondition ( $column, $words ) : string
hasIntegerKey ( $array ) : boolean

Описание методов

__construct() публичный Метод

public __construct ( $connection = null, $tableInfo = null )

applyCriterias() публичный Метод

public applyCriterias ( $sql, $parameters = [], $ordering = [], $limit, $offset )

applyLimitOffset() публичный Метод

Alters the sql to apply $limit and $offset. Default implementation is applicable for PostgreSQL, MySQL and SQLite.
public applyLimitOffset ( $sql, $limit, $offset ) : string
Результат string SQL with limit and offset.

applyOrdering() публичный Метод

public applyOrdering ( $sql, $ordering ) : string
Результат string modified SQL applied with ORDER BY.

bindArrayValues() публичный Метод

public bindArrayValues ( $command, $values )

bindColumnValues() публичный Метод

Bind the name-value pairs of $values where the array keys correspond to column names.
public bindColumnValues ( $command, $values )

createCommand() публичный Метод

public createCommand ( $sql ) : TDbCommand
Результат TDbCommand corresponding database command.

createCountCommand() публичный Метод

Creates a count(*) command for the table described in {@link setTableInfo TableInfo}.
public createCountCommand ( $where = '1=1', $parameters = [], $ordering = [], $limit, $offset ) : TDbCommand
Результат TDbCommand count command.

createDeleteCommand() публичный Метод

The conditions for delete is given by the $where argument and the parameters for the condition is given by $parameters.
public createDeleteCommand ( $where, $parameters = [] ) : TDbCommand
Результат TDbCommand delete command.

createFindCommand() публичный Метод

The tableName is obtained from the {@link setTableInfo TableInfo} property.
public createFindCommand ( $where = '1=1', $parameters = [], $ordering = [], $limit, $offset, $select = '*' ) : TDbCommand
Результат TDbCommand query command.

createInsertCommand() публичный Метод

Each array key in the $data array must correspond to the column name of the table (if a column allows to be null, it may be omitted) to be inserted with the corresponding array value.
public createInsertCommand ( $data ) : TDbCommand
Результат TDbCommand insert command

createUpdateCommand() публичный Метод

Each array key in the $data array must correspond to the column name to be updated with the corresponding array value.
public createUpdateCommand ( $data, $where, $parameters = [] ) : TDbCommand
Результат TDbCommand update command.

getColumnBindings() защищенный Метод

Create a name-value or position-value if $position=true binding strings.
protected getColumnBindings ( $values, $position = false ) : string
Результат string update column names with corresponding binding substrings.

getDbConnection() публичный Метод

public getDbConnection ( ) : TDbConnection
Результат TDbConnection database connection.

getInsertFieldBindings() защищенный Метод

Returns a list of insert field name and a list of binding names.
protected getInsertFieldBindings ( $values ) : array
Результат array tuple ($fields, $bindings)

getLastInsertID() публичный Метод

Iterate through all the columns and returns the last insert id of the first column that has a sequence or serial.
public getLastInsertID ( ) : mixed
Результат mixed last insert id, null if none is found.

getPdoType() публичный статический Метод

public static getPdoType ( $value ) : integer
Результат integer PDO parameter types.

getSearchCondition() защищенный Метод

protected getSearchCondition ( $column, $words ) : string
Результат string search condition for all words in one column.

getSearchExpression() публичный Метод

Computes the SQL condition for search a set of column using regular expression (or LIKE, depending on database implementation) to match a string of keywords (default matches all keywords).
public getSearchExpression ( $fields, $keywords ) : string
Результат string SQL search condition matching on a set of columns.

getSelectFieldList() публичный Метод

null will be expanded to full list of quoted table column names (quoting depends on database) array - Column names will be quoted if used as key or value of array array('col1', 'col2', 'col2') SELECT col1, col2, col3 FROM... - Column aliasing array('mycol1' => 'col1', 'mycol2' => 'COUNT(*)') SELECT col1 AS mycol1, COUNT(*) AS mycol2 FROM... - NULL and scalar values (strings will be quoted depending on database) array('col1' => 'my custom string', 'col2' => 1.0, 'col3' => 'NULL') SELECT "my custom string" AS col1, 1.0 AS col2, NULL AS col3 FROM... - If the *-wildcard char is used as key or value, add the full list of quoted table column names array('col1' => 'NULL', '*') SELECT col1, col2, col3, NULL AS col1 FROM...
С версии: 3.1.7
public getSelectFieldList ( $data = '*' ) : array
Результат array of generated fields - use implode(', ', $selectfieldlist) to collapse field list for usage

getTableInfo() публичный Метод

public getTableInfo ( )

hasIntegerKey() защищенный Метод

protected hasIntegerKey ( $array ) : boolean
Результат boolean true if any array key is an integer.

setDbConnection() публичный Метод

public setDbConnection ( $value )

setTableInfo() публичный Метод

public setTableInfo ( $value )