PHP Class Prado\Data\Common\TDbCommandBuilder

Since: 3.1
Inheritance: extends Prado\TComponent
Afficher le fichier Open project: pradosoft/prado Class Usage Examples

Méthodes publiques

Méthode Description
__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 )

Méthodes protégées

Méthode Description
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

Method Details

__construct() public méthode

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

applyCriterias() public méthode

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

applyLimitOffset() public méthode

Alters the sql to apply $limit and $offset. Default implementation is applicable for PostgreSQL, MySQL and SQLite.
public applyLimitOffset ( $sql, $limit, $offset ) : string
Résultat string SQL with limit and offset.

applyOrdering() public méthode

public applyOrdering ( $sql, $ordering ) : string
Résultat string modified SQL applied with ORDER BY.

bindArrayValues() public méthode

public bindArrayValues ( $command, $values )

bindColumnValues() public méthode

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

createCommand() public méthode

public createCommand ( $sql ) : TDbCommand
Résultat TDbCommand corresponding database command.

createCountCommand() public méthode

Creates a count(*) command for the table described in {@link setTableInfo TableInfo}.
public createCountCommand ( $where = '1=1', $parameters = [], $ordering = [], $limit, $offset ) : TDbCommand
Résultat TDbCommand count command.

createDeleteCommand() public méthode

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
Résultat TDbCommand delete command.

createFindCommand() public méthode

The tableName is obtained from the {@link setTableInfo TableInfo} property.
public createFindCommand ( $where = '1=1', $parameters = [], $ordering = [], $limit, $offset, $select = '*' ) : TDbCommand
Résultat TDbCommand query command.

createInsertCommand() public méthode

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
Résultat TDbCommand insert command

createUpdateCommand() public méthode

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
Résultat TDbCommand update command.

getColumnBindings() protected méthode

Create a name-value or position-value if $position=true binding strings.
protected getColumnBindings ( $values, $position = false ) : string
Résultat string update column names with corresponding binding substrings.

getDbConnection() public méthode

public getDbConnection ( ) : TDbConnection
Résultat TDbConnection database connection.

getInsertFieldBindings() protected méthode

Returns a list of insert field name and a list of binding names.
protected getInsertFieldBindings ( $values ) : array
Résultat array tuple ($fields, $bindings)

getLastInsertID() public méthode

Iterate through all the columns and returns the last insert id of the first column that has a sequence or serial.
public getLastInsertID ( ) : mixed
Résultat mixed last insert id, null if none is found.

getPdoType() public static méthode

public static getPdoType ( $value ) : integer
Résultat integer PDO parameter types.

getSearchCondition() protected méthode

protected getSearchCondition ( $column, $words ) : string
Résultat string search condition for all words in one column.

getSearchExpression() public méthode

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
Résultat string SQL search condition matching on a set of columns.

getSelectFieldList() public méthode

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...
Since: 3.1.7
public getSelectFieldList ( $data = '*' ) : array
Résultat array of generated fields - use implode(', ', $selectfieldlist) to collapse field list for usage

getTableInfo() public méthode

public getTableInfo ( )

hasIntegerKey() protected méthode

protected hasIntegerKey ( $array ) : boolean
Résultat boolean true if any array key is an integer.

setDbConnection() public méthode

public setDbConnection ( $value )

setTableInfo() public méthode

public setTableInfo ( $value )