Class \Prado\Data\Common\TDbCommandBuilder
TDbCommandBuilder provides basic methods to create query commands for tables
giving by {@see setTableInfo TableInfo} the property.
Class hierarchy
Author: Wei Zhuo <weizho[at]gmail[dot]com>Since: 3.1
public
|
__construct([null|TDbConnection $connection = null ][, null|TDbTableInfo $tableInfo = null ]) : mixed
The common __construct.
|
public
|
applyCriterias(mixed $sql[, mixed $parameters = [] ][, mixed $ordering = [] ][, mixed $limit = -1 ][, mixed $offset = -1 ]) : mixed
|
public
|
applyLimitOffset(string $sql[, int $limit = -1 ][, int $offset = -1 ]) : string
Alters the sql to apply $limit and $offset. Default implementation is applicable
for PostgreSQL, MySQL and SQLite.
|
public
|
|
public
|
|
public
|
bindColumnValues(TDbCommand $command, array<string|int, mixed> $values) : mixed
Bind the name-value pairs of $values where the array keys correspond to column names.
|
public
|
|
public
|
createCountCommand([string $where = '1=1' ][, array<string|int, mixed> $parameters = [] ][, array<string|int, mixed> $ordering = [] ][, int $limit = -1 ][, int $offset = -1 ]) : TDbCommand
Creates a count(*) command for the table described in {@see setTableInfo TableInfo}.
|
public
|
createDeleteCommand(string $where[, array<string|int, mixed> $parameters = [] ]) : TDbCommand
Creates a delete command for the table described in {@see setTableInfo TableInfo}.
The conditions for delete is given by the $where argument and the parameters for the condition is given by $parameters. |
public
|
createFindCommand([string $where = '1=1' ][, array<string|int, mixed> $parameters = [] ][, array<string|int, mixed> $ordering = [] ][, int $limit = -1 ][, int $offset = -1 ][, string $select = '*' ]) : TDbCommand
Appends the $where condition to the string "SELECT * FROM tableName WHERE ".
The tableName is obtained from the \Prado\Data\Common\setTableInfo property. |
public
|
createInsertCommand(array<string|int, mixed> $data) : TDbCommand
Creates an insert command for the table described in {@see setTableInfo TableInfo} for the given data.
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
|
createUpdateCommand(array<string|int, mixed> $data, string $where[, array<string|int, mixed> $parameters = [] ]) : TDbCommand
Creates an update command for the table described in {@see setTableInfo TableInfo} for the given data.
Each array key in the $data array must correspond to the column name to be updated with the corresponding array value. |
public
|
|
public
|
getLastInsertID() : mixed
Iterate through all the columns and returns the last insert id of the
first column that has a sequence or serial.
|
public
static
|
|
public
|
getSearchExpression(array<string|int, mixed> $fields, string $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).
|
public
|
getSelectFieldList([mixed $data = '*' ]) : array<string|int, mixed>
Different behavior depends on type of passed data
string
usage without modification
null will be expanded to full list of quoted table column names (quoting depends on database) array
|
public
|
|
public
|
|
public
|
|
protected
|
getColumnBindings(array<string|int, mixed> $values[, bool $position = false ]) : string
Create a name-value or position-value if $position=true binding strings.
|
protected
|
getInsertFieldBindings(object $values) : array<string|int, mixed>
Returns a list of insert field name and a list of binding names.
|
protected
|
|
protected
|
\Prado\TComponent::GLOBAL_RAISE_EVENT_LISTENER |