QueryBuilder
extends QueryBuilder
in package
QueryBuilder is the query builder for CUBRID databases (version 9.3.x and higher).
Tags
Table of Contents
Constants
- PARAM_PREFIX = ':qp'
- The prefix for automatically generated query binding parameters.
Properties
- $conditionClasses : array<string|int, string>
- $db : Connection
- $expressionBuilders : array<string|int, string>
- $separator : string
- $typeMap : array<string|int, mixed>
- $conditionBuilders : array<string|int, mixed>
- $conditionClasses : array<string|int, mixed>
- $expressionBuilders : array<string|int, string>|array<string|int, ExpressionBuilderInterface>
Methods
- __call() : mixed
- Calls the named method which is not a class method.
- __construct() : mixed
- Constructor.
- __get() : mixed
- Returns the value of an object property.
- __isset() : bool
- Checks if a property is set, i.e. defined and not null.
- __set() : mixed
- Sets value of an object property.
- __unset() : mixed
- Sets an object property to null.
- addCheck() : string
- Creates a SQL command for adding a check constraint to an existing table.
- addColumn() : string
- Builds a SQL statement for adding a new DB column.
- addCommentOnColumn() : string
- Builds a SQL command for adding comment to column.
- addCommentOnTable() : string
- Builds a SQL command for adding comment to table.
- addDefaultValue() : string
- Creates a SQL command for adding a default value constraint to an existing table.
- addForeignKey() : string
- Builds a SQL statement for adding a foreign key constraint to an existing table.
- addPrimaryKey() : string
- Builds a SQL statement for adding a primary key constraint to an existing table.
- addUnique() : string
- Creates a SQL command for adding an unique constraint to an existing table.
- alterColumn() : string
- Builds a SQL statement for changing the definition of a column.
- batchInsert() : string
- Generates a batch INSERT SQL statement.
- bindParam() : string
- Helper method to add $value to $params array using [[PARAM_PREFIX]].
- build() : array<string|int, mixed>
- Generates a SELECT SQL statement from a [[Query]] object.
- buildAndCondition() : string
- Connects two or more SQL expressions with the `AND` or `OR` operator.
- buildBetweenCondition() : string
- Creates an SQL expressions with the `BETWEEN` operator.
- buildColumns() : string
- Processes columns and properly quotes them if necessary.
- buildCondition() : string
- Parses the condition specification and generates the corresponding SQL expression.
- buildExistsCondition() : string
- Creates an SQL expressions with the `EXISTS` operator.
- buildExpression() : string
- Builds given $expression
- buildFrom() : string
- buildGroupBy() : string
- buildHashCondition() : string
- Creates a condition based on column-value pairs.
- buildHaving() : string
- buildInCondition() : string
- Creates an SQL expressions with the `IN` operator.
- buildJoin() : string
- buildLikeCondition() : string
- Creates an SQL expressions with the `LIKE` operator.
- buildLimit() : string
- buildNotCondition() : string
- Inverts an SQL expressions with `NOT` operator.
- buildOrderBy() : string
- buildOrderByAndLimit() : string
- Builds the ORDER BY and LIMIT/OFFSET clauses and appends them to the given SQL.
- buildSelect() : string
- buildSimpleCondition() : string
- Creates an SQL expressions like `"column" operator value`.
- buildUnion() : string
- buildWhere() : string
- buildWithQueries() : string
- canGetProperty() : bool
- Returns a value indicating whether a property can be read.
- canSetProperty() : bool
- Returns a value indicating whether a property can be set.
- checkIntegrity() : string
- Builds a SQL statement for enabling or disabling integrity check.
- className() : string
- Returns the fully qualified name of this class.
- createConditionFromArray() : ConditionInterface
- Transforms $condition defined in array format (as described in [[Query::where()]] to instance of [[yii\db\condition\ConditionInterface|ConditionInterface]] according to [[conditionClasses]] map.
- createIndex() : string
- Builds a SQL statement for creating a new index.
- createTable() : string
- Builds a SQL statement for creating a new DB table.
- createView() : string
- Creates a SQL View.
- delete() : string
- Creates a DELETE SQL statement.
- dropCheck() : string
- Creates a SQL command for dropping a check constraint.
- dropColumn() : string
- Builds a SQL statement for dropping a DB column.
- dropCommentFromColumn() : string
- Builds a SQL command for adding comment to column.
- dropCommentFromTable() : string
- Builds a SQL command for adding comment to table.
- dropDefaultValue() : string
- Creates a SQL command for dropping a default value constraint.
- dropForeignKey() : string
- Builds a SQL statement for dropping a foreign key constraint.
- dropIndex() : string
- Builds a SQL statement for dropping an index.
- dropPrimaryKey() : string
- Builds a SQL statement for removing a primary key constraint to an existing table.
- dropTable() : string
- Builds a SQL statement for dropping a DB table.
- dropUnique() : string
- Creates a SQL command for dropping an unique constraint.
- dropView() : string
- Drops a SQL View.
- executeResetSequence() : mixed
- Execute a SQL statement for resetting the sequence value of a table's primary key.
- getColumnType() : string
- Converts an abstract column type into a physical column type.
- getExpressionBuilder() : ExpressionBuilderInterface
- Gets object of [[ExpressionBuilderInterface]] that is suitable for $expression.
- hasMethod() : bool
- Returns a value indicating whether a method is defined.
- hasProperty() : bool
- Returns a value indicating whether a property is defined.
- init() : mixed
- Initializes the object.
- insert() : string
- Creates an INSERT SQL statement.
- renameColumn() : string
- Builds a SQL statement for renaming a column.
- renameTable() : string
- Builds a SQL statement for renaming a DB table.
- resetSequence() : string
- Creates a SQL statement for resetting the sequence value of a table's primary key.
- selectExists() : string
- Creates a SELECT EXISTS() SQL statement.
- setConditionClasses() : mixed
- Setter for [[conditionClasses]] property.
- setExpressionBuilders() : mixed
- Setter for [[expressionBuilders]] property.
- truncateTable() : string
- Builds a SQL statement for truncating a DB table.
- update() : string
- Creates an UPDATE SQL statement.
- upsert() : string
- Creates an SQL statement to insert rows into a database table if they do not already exist (matching unique constraints), or update them if they do.
- defaultConditionClasses() : array<string|int, mixed>
- Contains array of default condition classes. Extend this method, if you want to change default condition classes for the query builder. See [[conditionClasses]] docs for details.
- defaultExpressionBuilders() : array<string|int, mixed>
- Contains array of default expression builders. Extend this method and override it, if you want to change default expression builders for this query builder. See [[expressionBuilders]] docs for details.
- extractAlias() : bool|array<string|int, mixed>
- Extracts table alias if there is one or returns false
- hasLimit() : bool
- Checks to see if the given limit is effective.
- hasOffset() : bool
- Checks to see if the given offset is effective.
- prepareInsertSelectSubQuery() : array<string|int, mixed>
- Prepare select-subquery and field names for INSERT INTO ... SELECT SQL statement.
- prepareInsertValues() : array<string|int, mixed>
- Prepares a `VALUES` part for an `INSERT` SQL statement.
- prepareUpdateSets() : array<string|int, mixed>
- Prepares a `SET` parts for an `UPDATE` SQL statement.
- prepareUpsertColumns() : array<string|int, mixed>
- getColumnDefinition() : string|null
- Gets column definition.
- getTableUniqueColumnNames() : array<string|int, string>
- Returns all column names belonging to constraints enforcing uniqueness (`PRIMARY KEY`, `UNIQUE INDEX`, etc.) for the named table removing constraints which did not cover the specified column list.
- quoteTableNames() : array<string|int, mixed>
- Quotes table names passed.
Constants
PARAM_PREFIX
The prefix for automatically generated query binding parameters.
public
mixed
PARAM_PREFIX
= ':qp'
Properties
$conditionClasses write-only
public
array<string|int, string>
$conditionClasses
Map of condition aliases to condition classes. For example:
php ['LIKE' => yii\db\condition\LikeCondition::class]
.
$db
public
Connection
$db
the database connection.
$expressionBuilders write-only
public
array<string|int, string>
$expressionBuilders
Array of builders that should be merged with the pre-defined ones in [[expressionBuilders]] property.
$separator
public
string
$separator
= ' '
the separator between different fragments of a SQL statement. Defaults to an empty space. This is mainly used by [[build()]] when generating a SQL statement.
$typeMap
public
array<string|int, mixed>
$typeMap
= [\yii\db\cubrid\Schema::TYPE_PK => 'int NOT NULL AUTO_INCREMENT PRIMARY KEY', \yii\db\cubrid\Schema::TYPE_UPK => 'int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY', \yii\db\cubrid\Schema::TYPE_BIGPK => 'bigint NOT NULL AUTO_INCREMENT PRIMARY KEY', \yii\db\cubrid\Schema::TYPE_UBIGPK => 'bigint UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY', \yii\db\cubrid\Schema::TYPE_CHAR => 'char(1)', \yii\db\cubrid\Schema::TYPE_STRING => 'varchar(255)', \yii\db\cubrid\Schema::TYPE_TEXT => 'varchar', \yii\db\cubrid\Schema::TYPE_TINYINT => 'smallint', \yii\db\cubrid\Schema::TYPE_SMALLINT => 'smallint', \yii\db\cubrid\Schema::TYPE_INTEGER => 'int', \yii\db\cubrid\Schema::TYPE_BIGINT => 'bigint', \yii\db\cubrid\Schema::TYPE_FLOAT => 'float(7)', \yii\db\cubrid\Schema::TYPE_DOUBLE => 'double(15)', \yii\db\cubrid\Schema::TYPE_DECIMAL => 'decimal(10,0)', \yii\db\cubrid\Schema::TYPE_DATETIME => 'datetime', \yii\db\cubrid\Schema::TYPE_TIMESTAMP => 'timestamp', \yii\db\cubrid\Schema::TYPE_TIME => 'time', \yii\db\cubrid\Schema::TYPE_DATE => 'date', \yii\db\cubrid\Schema::TYPE_BINARY => 'blob', \yii\db\cubrid\Schema::TYPE_BOOLEAN => 'smallint', \yii\db\cubrid\Schema::TYPE_MONEY => 'decimal(19,4)']
mapping from abstract column types (keys) to physical column types (values).
$conditionBuilders
protected
array<string|int, mixed>
$conditionBuilders
= []
map of query condition to builder methods. These methods are used by [[buildCondition]] to build SQL conditions from array syntax.
Tags
$conditionClasses
protected
array<string|int, mixed>
$conditionClasses
= []
map of condition aliases to condition classes. For example:
return [
'LIKE' => yii\db\condition\LikeCondition::class,
];
This property is used by [[createConditionFromArray]] method. See default condition classes list in [[defaultConditionClasses()]] method.
In case you want to add custom conditions support, use the [[setConditionClasses()]] method.
Tags
$expressionBuilders
protected
array<string|int, string>|array<string|int, ExpressionBuilderInterface>
$expressionBuilders
= []
maps expression class to expression builder class. For example:
[
yii\db\Expression::class => yii\db\ExpressionBuilder::class
]
This property is mainly used by [[buildExpression()]] to build SQL expressions form expression objects. See default values in [[defaultExpressionBuilders()]] method.
To override existing builders or add custom, use [[setExpressionBuilder()]] method. New items will be added to the end of this array.
To find a builder, [[buildExpression()]] will check the expression class for its exact presence in this map. In case it is NOT present, the array will be iterated in reverse direction, checking whether the expression extends the class, defined in this map.
Tags
Methods
__call()
Calls the named method which is not a class method.
public
__call(string $name, array<string|int, mixed> $params) : mixed
Do not call this method directly as it is a PHP magic method that will be implicitly called when an unknown method is being invoked.
Parameters
- $name : string
-
the method name
- $params : array<string|int, mixed>
-
method parameters
Tags
Return values
mixed —the method return value
__construct()
Constructor.
public
__construct(Connection $connection[, array<string|int, mixed> $config = [] ]) : mixed
Parameters
- $connection : Connection
-
the database connection.
- $config : array<string|int, mixed> = []
-
name-value pairs that will be used to initialize the object properties
__get()
Returns the value of an object property.
public
__get(string $name) : mixed
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $value = $object->property;
.
Parameters
- $name : string
-
the property name
Tags
Return values
mixed —the property value
__isset()
Checks if a property is set, i.e. defined and not null.
public
__isset(string $name) : bool
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing isset($object->property)
.
Note that if the property is not defined, false will be returned.
Parameters
- $name : string
-
the property name or the event name
Tags
Return values
bool —whether the named property is set (not null).
__set()
Sets value of an object property.
public
__set(string $name, mixed $value) : mixed
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $object->property = $value;
.
Parameters
- $name : string
-
the property name or the event name
- $value : mixed
-
the property value
Tags
__unset()
Sets an object property to null.
public
__unset(string $name) : mixed
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing unset($object->property)
.
Note that if the property is not defined, this method will do nothing. If the property is read-only, it will throw an exception.
Parameters
- $name : string
-
the property name
Tags
addCheck()
Creates a SQL command for adding a check constraint to an existing table.
public
addCheck(mixed $name, mixed $table, mixed $expression) : string
Parameters
- $name : mixed
-
the name of the check constraint. The name will be properly quoted by the method.
- $table : mixed
-
the table that the check constraint will be added to. The name will be properly quoted by the method.
- $expression : mixed
-
the SQL of the
CHECK
constraint.
Tags
Return values
string —the SQL statement for adding a check constraint to an existing table.
addColumn()
Builds a SQL statement for adding a new DB column.
public
addColumn(string $table, string $column, string $type) : string
Parameters
- $table : string
-
the table that the new column will be added to. The table name will be properly quoted by the method.
- $column : string
-
the name of the new column. The name will be properly quoted by the method.
- $type : string
-
the column type. The [[getColumnType()]] method will be invoked to convert abstract column type (if any) into the physical one. Anything that is not recognized as abstract type will be kept in the generated SQL. For example, 'string' will be turned into 'varchar(255)', while 'string not null' will become 'varchar(255) not null'.
Return values
string —the SQL statement for adding a new column.
addCommentOnColumn()
Builds a SQL command for adding comment to column.
public
addCommentOnColumn(mixed $table, mixed $column, mixed $comment) : string
Parameters
- $table : mixed
-
the table whose column is to be commented. The table name will be properly quoted by the method.
- $column : mixed
-
the name of the column to be commented. The column name will be properly quoted by the method.
- $comment : mixed
-
the text of the comment to be added. The comment will be properly quoted by the method.
Tags
Return values
string —the SQL statement for adding comment on column
addCommentOnTable()
Builds a SQL command for adding comment to table.
public
addCommentOnTable(mixed $table, mixed $comment) : string
Parameters
- $table : mixed
-
the table whose column is to be commented. The table name will be properly quoted by the method.
- $comment : mixed
-
the text of the comment to be added. The comment will be properly quoted by the method.
Tags
Return values
string —the SQL statement for adding comment on table
addDefaultValue()
Creates a SQL command for adding a default value constraint to an existing table.
public
addDefaultValue(string $name, string $table, string $column, mixed $value) : string
Parameters
- $name : string
-
the name of the default value constraint. The name will be properly quoted by the method.
- $table : string
-
the table that the default value constraint will be added to. The name will be properly quoted by the method.
- $column : string
-
the name of the column to that the constraint will be added on. The name will be properly quoted by the method.
- $value : mixed
-
default value.
Tags
Return values
string —the SQL statement for adding a default value constraint to an existing table.
addForeignKey()
Builds a SQL statement for adding a foreign key constraint to an existing table.
public
addForeignKey(string $name, string $table, string|array<string|int, mixed> $columns, string $refTable, string|array<string|int, mixed> $refColumns[, string|null $delete = null ][, string|null $update = null ]) : string
The method will properly quote the table and column names.
Parameters
- $name : string
-
the name of the foreign key constraint.
- $table : string
-
the table that the foreign key constraint will be added to.
- $columns : string|array<string|int, mixed>
-
the name of the column to that the constraint will be added on. If there are multiple columns, separate them with commas or use an array to represent them.
- $refTable : string
-
the table that the foreign key references to.
- $refColumns : string|array<string|int, mixed>
-
the name of the column that the foreign key references to. If there are multiple columns, separate them with commas or use an array to represent them.
- $delete : string|null = null
-
the ON DELETE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
- $update : string|null = null
-
the ON UPDATE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
Return values
string —the SQL statement for adding a foreign key constraint to an existing table.
addPrimaryKey()
Builds a SQL statement for adding a primary key constraint to an existing table.
public
addPrimaryKey(string $name, string $table, string|array<string|int, mixed> $columns) : string
Parameters
- $name : string
-
the name of the primary key constraint.
- $table : string
-
the table that the primary key constraint will be added to.
- $columns : string|array<string|int, mixed>
-
comma separated string or array of columns that the primary key will consist of.
Return values
string —the SQL statement for adding a primary key constraint to an existing table.
addUnique()
Creates a SQL command for adding an unique constraint to an existing table.
public
addUnique(string $name, string $table, string|array<string|int, mixed> $columns) : string
Parameters
- $name : string
-
the name of the unique constraint. The name will be properly quoted by the method.
- $table : string
-
the table that the unique constraint will be added to. The name will be properly quoted by the method.
- $columns : string|array<string|int, mixed>
-
the name of the column to that the constraint will be added on. If there are multiple columns, separate them with commas. The name will be properly quoted by the method.
Tags
Return values
string —the SQL statement for adding an unique constraint to an existing table.
alterColumn()
Builds a SQL statement for changing the definition of a column.
public
alterColumn(string $table, string $column, string $type) : string
Parameters
- $table : string
-
the table whose column is to be changed. The table name will be properly quoted by the method.
- $column : string
-
the name of the column to be changed. The name will be properly quoted by the method.
- $type : string
-
the new column type. The [[getColumnType()]] method will be invoked to convert abstract column type (if any) into the physical one. Anything that is not recognized as abstract type will be kept in the generated SQL. For example, 'string' will be turned into 'varchar(255)', while 'string not null' will become 'varchar(255) not null'.
Return values
string —the SQL statement for changing the definition of a column.
batchInsert()
Generates a batch INSERT SQL statement.
public
batchInsert(string $table, array<string|int, mixed> $columns, array<string|int, mixed>|Generator $rows[, array<string|int, mixed> &$params = [] ]) : string
For example,
$sql = $queryBuilder->batchInsert('user', ['name', 'age'], [
['Tom', 30],
['Jane', 20],
['Linda', 25],
]);
Note that the values in each row must match the corresponding column names.
The method will properly escape the column names, and quote the values to be inserted.
Parameters
- $table : string
-
the table that new rows will be inserted into.
- $columns : array<string|int, mixed>
-
the column names
- $rows : array<string|int, mixed>|Generator
-
the rows to be batch inserted into the table
- $params : array<string|int, mixed> = []
-
the binding parameters. This parameter exists since 2.0.14
Return values
string —the batch INSERT SQL statement
bindParam()
Helper method to add $value to $params array using [[PARAM_PREFIX]].
public
bindParam(string|null $value, array<string|int, mixed> &$params) : string
Parameters
- $value : string|null
- $params : array<string|int, mixed>
-
passed by reference
Tags
Return values
string —the placeholder name in $params array
build()
Generates a SELECT SQL statement from a [[Query]] object.
public
build(Query $query[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $query : Query
-
the [[Query]] object from which the SQL statement will be generated.
- $params : array<string|int, mixed> = []
-
the parameters to be bound to the generated SQL statement. These parameters will be included in the result with the additional parameters generated during the query building process.
Return values
array<string|int, mixed> —the generated SQL statement (the first array element) and the corresponding
parameters to be bound to the SQL statement (the second array element). The parameters returned
include those provided in $params
.
buildAndCondition()
Connects two or more SQL expressions with the `AND` or `OR` operator.
public
buildAndCondition(string $operator, array<string|int, mixed> $operands, array<string|int, mixed> &$params) : string
Parameters
- $operator : string
-
the operator to use for connecting the given operands
- $operands : array<string|int, mixed>
-
the SQL expressions to connect.
- $params : array<string|int, mixed>
-
the binding parameters to be populated
Tags
Return values
string —the generated SQL expression
buildBetweenCondition()
Creates an SQL expressions with the `BETWEEN` operator.
public
buildBetweenCondition(string $operator, array<string|int, mixed> $operands, array<string|int, mixed> &$params) : string
Parameters
- $operator : string
-
the operator to use (e.g.
BETWEEN
orNOT BETWEEN
) - $operands : array<string|int, mixed>
-
the first operand is the column name. The second and third operands describe the interval that column value should be in.
- $params : array<string|int, mixed>
-
the binding parameters to be populated
Tags
Return values
string —the generated SQL expression
buildColumns()
Processes columns and properly quotes them if necessary.
public
buildColumns(string|array<string|int, mixed> $columns) : string
It will join all columns into a string with comma as separators.
Parameters
- $columns : string|array<string|int, mixed>
-
the columns to be processed
Return values
string —the processing result
buildCondition()
Parses the condition specification and generates the corresponding SQL expression.
public
buildCondition(string|array<string|int, mixed>|ExpressionInterface $condition, array<string|int, mixed> &$params) : string
Parameters
- $condition : string|array<string|int, mixed>|ExpressionInterface
-
the condition specification. Please refer to [[Query::where()]] on how to specify a condition.
- $params : array<string|int, mixed>
-
the binding parameters to be populated
Return values
string —the generated SQL expression
buildExistsCondition()
Creates an SQL expressions with the `EXISTS` operator.
public
buildExistsCondition(string $operator, array<string|int, mixed> $operands, array<string|int, mixed> &$params) : string
Parameters
- $operator : string
-
the operator to use (e.g.
EXISTS
orNOT EXISTS
) - $operands : array<string|int, mixed>
-
contains only one element which is a [[Query]] object representing the sub-query.
- $params : array<string|int, mixed>
-
the binding parameters to be populated
Tags
Return values
string —the generated SQL expression
buildExpression()
Builds given $expression
public
buildExpression(ExpressionInterface $expression[, array<string|int, mixed> &$params = [] ]) : string
Parameters
- $expression : ExpressionInterface
-
the expression to be built
- $params : array<string|int, mixed> = []
-
the parameters to be bound to the generated SQL statement. These parameters will be included in the result with the additional parameters generated during the expression building process.
Tags
Return values
string —the SQL statement that will not be neither quoted nor encoded before passing to DBMS
buildFrom()
public
buildFrom(array<string|int, mixed> $tables, array<string|int, mixed> &$params) : string
Parameters
- $tables : array<string|int, mixed>
- $params : array<string|int, mixed>
-
the binding parameters to be populated
Return values
string —the FROM clause built from [[Query::$from]].
buildGroupBy()
public
buildGroupBy(array<string|int, mixed> $columns) : string
Parameters
- $columns : array<string|int, mixed>
Return values
string —the GROUP BY clause
buildHashCondition()
Creates a condition based on column-value pairs.
public
buildHashCondition(array<string|int, mixed> $condition, array<string|int, mixed> &$params) : string
Parameters
- $condition : array<string|int, mixed>
-
the condition specification.
- $params : array<string|int, mixed>
-
the binding parameters to be populated
Tags
Return values
string —the generated SQL expression
buildHaving()
public
buildHaving(string|array<string|int, mixed> $condition, array<string|int, mixed> &$params) : string
Parameters
- $condition : string|array<string|int, mixed>
- $params : array<string|int, mixed>
-
the binding parameters to be populated
Return values
string —the HAVING clause built from [[Query::$having]].
buildInCondition()
Creates an SQL expressions with the `IN` operator.
public
buildInCondition(string $operator, array<string|int, mixed> $operands, array<string|int, mixed> &$params) : string
Parameters
- $operator : string
-
the operator to use (e.g.
IN
orNOT IN
) - $operands : array<string|int, mixed>
-
the first operand is the column name. If it is an array a composite IN condition will be generated. The second operand is an array of values that column value should be among. If it is an empty array the generated expression will be a
false
value if operator isIN
and empty if operator isNOT IN
. - $params : array<string|int, mixed>
-
the binding parameters to be populated
Tags
Return values
string —the generated SQL expression
buildJoin()
public
buildJoin(array<string|int, mixed> $joins, array<string|int, mixed> &$params) : string
Parameters
- $joins : array<string|int, mixed>
- $params : array<string|int, mixed>
-
the binding parameters to be populated
Tags
Return values
string —the JOIN clause built from [[Query::$join]].
buildLikeCondition()
Creates an SQL expressions with the `LIKE` operator.
public
buildLikeCondition(string $operator, array<string|int, mixed> $operands, array<string|int, mixed> &$params) : string
Parameters
- $operator : string
-
the operator to use (e.g.
LIKE
,NOT LIKE
,OR LIKE
orOR NOT LIKE
) - $operands : array<string|int, mixed>
-
an array of two or three operands
- The first operand is the column name.
- The second operand is a single value or an array of values that column value
should be compared with. If it is an empty array the generated expression will
be a
false
value if operator isLIKE
orOR LIKE
, and empty if operator isNOT LIKE
orOR NOT LIKE
. - An optional third operand can also be provided to specify how to escape special characters
in the value(s). The operand should be an array of mappings from the special characters to their
escaped counterparts. If this operand is not provided, a default escape mapping will be used.
You may use
false
or an empty array to indicate the values are already escaped and no escape should be applied. Note that when using an escape mapping (or the third operand is not provided), the values will be automatically enclosed within a pair of percentage characters.
- $params : array<string|int, mixed>
-
the binding parameters to be populated
Tags
Return values
string —the generated SQL expression
buildLimit()
public
buildLimit(mixed $limit, mixed $offset) : string
Parameters
- $limit : mixed
- $offset : mixed
Return values
string —the LIMIT and OFFSET clauses
buildNotCondition()
Inverts an SQL expressions with `NOT` operator.
public
buildNotCondition(string $operator, array<string|int, mixed> $operands, array<string|int, mixed> &$params) : string
Parameters
- $operator : string
-
the operator to use for connecting the given operands
- $operands : array<string|int, mixed>
-
the SQL expressions to connect.
- $params : array<string|int, mixed>
-
the binding parameters to be populated
Tags
Return values
string —the generated SQL expression
buildOrderBy()
public
buildOrderBy(array<string|int, mixed> $columns) : string
Parameters
- $columns : array<string|int, mixed>
Return values
string —the ORDER BY clause built from [[Query::$orderBy]].
buildOrderByAndLimit()
Builds the ORDER BY and LIMIT/OFFSET clauses and appends them to the given SQL.
public
buildOrderByAndLimit(string $sql, array<string|int, mixed> $orderBy, int $limit, int $offset) : string
Parameters
- $sql : string
-
the existing SQL (without ORDER BY/LIMIT/OFFSET)
- $orderBy : array<string|int, mixed>
-
the order by columns. See [[Query::orderBy]] for more details on how to specify this parameter.
- $limit : int
-
the limit number. See [[Query::limit]] for more details.
- $offset : int
-
the offset number. See [[Query::offset]] for more details.
Return values
string —the SQL completed with ORDER BY/LIMIT/OFFSET (if any)
buildSelect()
public
buildSelect(array<string|int, mixed> $columns, array<string|int, mixed> &$params[, bool $distinct = false ][, string|null $selectOption = null ]) : string
Parameters
- $columns : array<string|int, mixed>
- $params : array<string|int, mixed>
-
the binding parameters to be populated
- $distinct : bool = false
- $selectOption : string|null = null
Return values
string —the SELECT clause built from [[Query::$select]].
buildSimpleCondition()
Creates an SQL expressions like `"column" operator value`.
public
buildSimpleCondition(string $operator, array<string|int, mixed> $operands, array<string|int, mixed> &$params) : string
Parameters
- $operator : string
-
the operator to use. Anything could be used e.g.
>
,<=
, etc. - $operands : array<string|int, mixed>
-
contains two column names.
- $params : array<string|int, mixed>
-
the binding parameters to be populated
Tags
Return values
string —the generated SQL expression
buildUnion()
public
buildUnion(array<string|int, mixed> $unions, array<string|int, mixed> &$params) : string
Parameters
- $unions : array<string|int, mixed>
- $params : array<string|int, mixed>
-
the binding parameters to be populated
Return values
string —the UNION clause built from [[Query::$union]].
buildWhere()
public
buildWhere(string|array<string|int, mixed> $condition, array<string|int, mixed> &$params) : string
Parameters
- $condition : string|array<string|int, mixed>
- $params : array<string|int, mixed>
-
the binding parameters to be populated
Return values
string —the WHERE clause built from [[Query::$where]].
buildWithQueries()
public
buildWithQueries(array<string|int, mixed> $withs, array<string|int, mixed> &$params) : string
Parameters
- $withs : array<string|int, mixed>
-
of configurations for each WITH query
- $params : array<string|int, mixed>
-
the binding parameters to be populated
Tags
Return values
string —compiled WITH prefix of query including nested queries
canGetProperty()
Returns a value indicating whether a property can be read.
public
canGetProperty(string $name[, bool $checkVars = true ]) : bool
A property is readable if:
- the class has a getter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
Parameters
- $name : string
-
the property name
- $checkVars : bool = true
-
whether to treat member variables as properties
Tags
Return values
bool —whether the property can be read
canSetProperty()
Returns a value indicating whether a property can be set.
public
canSetProperty(string $name[, bool $checkVars = true ]) : bool
A property is writable if:
- the class has a setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
Parameters
- $name : string
-
the property name
- $checkVars : bool = true
-
whether to treat member variables as properties
Tags
Return values
bool —whether the property can be written
checkIntegrity()
Builds a SQL statement for enabling or disabling integrity check.
public
checkIntegrity([bool $check = true ][, string $schema = '' ][, string $table = '' ]) : string
Parameters
- $check : bool = true
-
whether to turn on or off the integrity check.
- $schema : string = ''
-
the schema of the tables. Defaults to empty string, meaning the current or default schema.
- $table : string = ''
-
the table name. Defaults to empty string, meaning that no table will be changed.
Tags
Return values
string —the SQL statement for checking integrity
className()
Returns the fully qualified name of this class.
public
static className() : string
Tags
Return values
string —the fully qualified name of this class.
createConditionFromArray()
Transforms $condition defined in array format (as described in [[Query::where()]] to instance of [[yii\db\condition\ConditionInterface|ConditionInterface]] according to [[conditionClasses]] map.
public
createConditionFromArray(string|array<string|int, mixed> $condition) : ConditionInterface
Parameters
- $condition : string|array<string|int, mixed>
Tags
Return values
ConditionInterfacecreateIndex()
Builds a SQL statement for creating a new index.
public
createIndex(string $name, string $table, string|array<string|int, mixed> $columns[, bool $unique = false ]) : string
Parameters
- $name : string
-
the name of the index. The name will be properly quoted by the method.
- $table : string
-
the table that the new index will be created for. The table name will be properly quoted by the method.
- $columns : string|array<string|int, mixed>
-
the column(s) that should be included in the index. If there are multiple columns, separate them with commas or use an array to represent them. Each column name will be properly quoted by the method, unless a parenthesis is found in the name.
- $unique : bool = false
-
whether to add UNIQUE constraint on the created index.
Return values
string —the SQL statement for creating a new index.
createTable()
Builds a SQL statement for creating a new DB table.
public
createTable(string $table, array<string|int, mixed> $columns[, string|null $options = null ]) : string
The columns in the new table should be specified as name-definition pairs (e.g. 'name' => 'string'), where name stands for a column name which will be properly quoted by the method, and definition stands for the column type which must contain an abstract DB type. The [[getColumnType()]] method will be invoked to convert any abstract type into a physical one.
If a column is specified with definition only (e.g. 'PRIMARY KEY (name, type)'), it will be directly inserted into the generated SQL.
For example,
$sql = $queryBuilder->createTable('user', [
'id' => 'pk',
'name' => 'string',
'age' => 'integer',
'column_name double precision null default null', # definition only example
]);
Parameters
- $table : string
-
the name of the table to be created. The name will be properly quoted by the method.
- $columns : array<string|int, mixed>
-
the columns (name => definition) in the new table.
- $options : string|null = null
-
additional SQL fragment that will be appended to the generated SQL.
Return values
string —the SQL statement for creating a new DB table.
createView()
Creates a SQL View.
public
createView(string $viewName, string|Query $subQuery) : string
Parameters
- $viewName : string
-
the name of the view to be created.
- $subQuery : string|Query
-
the select statement which defines the view. This can be either a string or a [[Query]] object.
Tags
Return values
string —the CREATE VIEW
SQL statement.
delete()
Creates a DELETE SQL statement.
public
delete(string $table, array<string|int, mixed>|string $condition, array<string|int, mixed> &$params) : string
For example,
$sql = $queryBuilder->delete('user', 'status = 0');
The method will properly escape the table and column names.
Parameters
- $table : string
-
the table where the data will be deleted from.
- $condition : array<string|int, mixed>|string
-
the condition that will be put in the WHERE part. Please refer to [[Query::where()]] on how to specify condition.
- $params : array<string|int, mixed>
-
the binding parameters that will be modified by this method so that they can be bound to the DB command later.
Return values
string —the DELETE SQL
dropCheck()
Creates a SQL command for dropping a check constraint.
public
dropCheck(mixed $name, mixed $table) : string
Parameters
- $name : mixed
-
the name of the check constraint to be dropped. The name will be properly quoted by the method.
- $table : mixed
-
the table whose check constraint is to be dropped. The name will be properly quoted by the method.
Tags
Return values
string —the SQL statement for dropping a check constraint.
dropColumn()
Builds a SQL statement for dropping a DB column.
public
dropColumn(string $table, string $column) : string
Parameters
- $table : string
-
the table whose column is to be dropped. The name will be properly quoted by the method.
- $column : string
-
the name of the column to be dropped. The name will be properly quoted by the method.
Return values
string —the SQL statement for dropping a DB column.
dropCommentFromColumn()
Builds a SQL command for adding comment to column.
public
dropCommentFromColumn(mixed $table, mixed $column) : string
Parameters
- $table : mixed
-
the table whose column is to be commented. The table name will be properly quoted by the method.
- $column : mixed
-
the name of the column to be commented. The column name will be properly quoted by the method.
Tags
Return values
string —the SQL statement for adding comment on column
dropCommentFromTable()
Builds a SQL command for adding comment to table.
public
dropCommentFromTable(mixed $table) : string
Parameters
- $table : mixed
-
the table whose column is to be commented. The table name will be properly quoted by the method.
Tags
Return values
string —the SQL statement for adding comment on column
dropDefaultValue()
Creates a SQL command for dropping a default value constraint.
public
dropDefaultValue(string $name, string $table) : string
Parameters
- $name : string
-
the name of the default value constraint to be dropped. The name will be properly quoted by the method.
- $table : string
-
the table whose default value constraint is to be dropped. The name will be properly quoted by the method.
Tags
Return values
string —the SQL statement for dropping a default value constraint.
dropForeignKey()
Builds a SQL statement for dropping a foreign key constraint.
public
dropForeignKey(string $name, string $table) : string
Parameters
- $name : string
-
the name of the foreign key constraint to be dropped. The name will be properly quoted by the method.
- $table : string
-
the table whose foreign is to be dropped. The name will be properly quoted by the method.
Return values
string —the SQL statement for dropping a foreign key constraint.
dropIndex()
Builds a SQL statement for dropping an index.
public
dropIndex(mixed $name, mixed $table) : string
Parameters
- $name : mixed
-
the name of the index to be dropped. The name will be properly quoted by the method.
- $table : mixed
-
the table whose index is to be dropped. The name will be properly quoted by the method.
Tags
Return values
string —the SQL statement for dropping an index.
dropPrimaryKey()
Builds a SQL statement for removing a primary key constraint to an existing table.
public
dropPrimaryKey(string $name, string $table) : string
Parameters
- $name : string
-
the name of the primary key constraint to be removed.
- $table : string
-
the table that the primary key constraint will be removed from.
Return values
string —the SQL statement for removing a primary key constraint from an existing table.
dropTable()
Builds a SQL statement for dropping a DB table.
public
dropTable(string $table) : string
Parameters
- $table : string
-
the table to be dropped. The name will be properly quoted by the method.
Return values
string —the SQL statement for dropping a DB table.
dropUnique()
Creates a SQL command for dropping an unique constraint.
public
dropUnique(string $name, string $table) : string
Parameters
- $name : string
-
the name of the unique constraint to be dropped. The name will be properly quoted by the method.
- $table : string
-
the table whose unique constraint is to be dropped. The name will be properly quoted by the method.
Tags
Return values
string —the SQL statement for dropping an unique constraint.
dropView()
Drops a SQL View.
public
dropView(string $viewName) : string
Parameters
- $viewName : string
-
the name of the view to be dropped.
Tags
Return values
string —the DROP VIEW
SQL statement.
executeResetSequence()
Execute a SQL statement for resetting the sequence value of a table's primary key.
public
executeResetSequence(string $table[, array<string|int, mixed>|string|null $value = null ]) : mixed
Reason for execute is that some databases (Oracle) need several queries to do so. The sequence is reset such that the primary key of the next new row inserted will have the specified value or the maximum existing value +1.
Parameters
- $table : string
-
the name of the table whose primary key sequence is reset
- $value : array<string|int, mixed>|string|null = null
-
the value for the primary key of the next new row inserted. If this is not set, the next new row's primary key will have the maximum existing value +1.
Tags
getColumnType()
Converts an abstract column type into a physical column type.
public
getColumnType(string|ColumnSchemaBuilder $type) : string
The conversion is done using the type map specified in [[typeMap]]. The following abstract column types are supported (using MySQL as an example to explain the corresponding physical types):
-
pk
: an auto-incremental primary key type, will be converted into "int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY" -
bigpk
: an auto-incremental primary key type, will be converted into "bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY" -
upk
: an unsigned auto-incremental primary key type, will be converted into "int(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY" -
char
: char type, will be converted into "char(1)" -
string
: string type, will be converted into "varchar(255)" -
text
: a long string type, will be converted into "text" -
smallint
: a small integer type, will be converted into "smallint(6)" -
integer
: integer type, will be converted into "int(11)" -
bigint
: a big integer type, will be converted into "bigint(20)" -
boolean
: boolean type, will be converted into "tinyint(1)" - `float``: float number type, will be converted into "float"
-
decimal
: decimal number type, will be converted into "decimal" -
datetime
: datetime type, will be converted into "datetime" -
timestamp
: timestamp type, will be converted into "timestamp" -
time
: time type, will be converted into "time" -
date
: date type, will be converted into "date" -
money
: money type, will be converted into "decimal(19,4)" -
binary
: binary data type, will be converted into "blob"
If the abstract type contains two or more parts separated by spaces (e.g. "string NOT NULL"), then only the first part will be converted, and the rest of the parts will be appended to the converted result. For example, 'string NOT NULL' is converted to 'varchar(255) NOT NULL'.
For some of the abstract types you can also specify a length or precision constraint
by appending it in round brackets directly to the type.
For example string(32)
will be converted into "varchar(32)" on a MySQL database.
If the underlying DBMS does not support these kind of constraints for a type it will
be ignored.
If a type cannot be found in [[typeMap]], it will be returned without any change.
Parameters
- $type : string|ColumnSchemaBuilder
-
abstract column type
Return values
string —physical column type.
getExpressionBuilder()
Gets object of [[ExpressionBuilderInterface]] that is suitable for $expression.
public
getExpressionBuilder(ExpressionInterface $expression) : ExpressionBuilderInterface
Uses [[expressionBuilders]] array to find a suitable builder class.
Parameters
- $expression : ExpressionInterface
Tags
Return values
ExpressionBuilderInterfacehasMethod()
Returns a value indicating whether a method is defined.
public
hasMethod(string $name) : bool
The default implementation is a call to php function method_exists()
.
You may override this method when you implemented the php magic method __call()
.
Parameters
- $name : string
-
the method name
Return values
bool —whether the method is defined
hasProperty()
Returns a value indicating whether a property is defined.
public
hasProperty(string $name[, bool $checkVars = true ]) : bool
A property is defined if:
- the class has a getter or setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
Parameters
- $name : string
-
the property name
- $checkVars : bool = true
-
whether to treat member variables as properties
Tags
Return values
bool —whether the property is defined
init()
Initializes the object.
public
init() : mixed
insert()
Creates an INSERT SQL statement.
public
insert(string $table, array<string|int, mixed>|Query $columns, array<string|int, mixed> &$params) : string
For example,
$sql = $queryBuilder->insert('user', [
'name' => 'Sam',
'age' => 30,
], $params);
The method will properly escape the table and column names.
Parameters
- $table : string
-
the table that new rows will be inserted into.
- $columns : array<string|int, mixed>|Query
-
the column data (name => value) to be inserted into the table or instance of [[yii\db\Query|Query]] to perform INSERT INTO ... SELECT SQL statement. Passing of [[yii\db\Query|Query]] is available since version 2.0.11.
- $params : array<string|int, mixed>
-
the binding parameters that will be generated by this method. They should be bound to the DB command later.
Return values
string —the INSERT SQL
renameColumn()
Builds a SQL statement for renaming a column.
public
renameColumn(string $table, string $oldName, string $newName) : string
Parameters
- $table : string
-
the table whose column is to be renamed. The name will be properly quoted by the method.
- $oldName : string
-
the old name of the column. The name will be properly quoted by the method.
- $newName : string
-
the new name of the column. The name will be properly quoted by the method.
Return values
string —the SQL statement for renaming a DB column.
renameTable()
Builds a SQL statement for renaming a DB table.
public
renameTable(string $oldName, string $newName) : string
Parameters
- $oldName : string
-
the table to be renamed. The name will be properly quoted by the method.
- $newName : string
-
the new table name. The name will be properly quoted by the method.
Return values
string —the SQL statement for renaming a DB table.
resetSequence()
Creates a SQL statement for resetting the sequence value of a table's primary key.
public
resetSequence(string $tableName[, mixed $value = null ]) : string
The sequence will be reset such that the primary key of the next new row inserted will have the specified value or 1.
Parameters
- $tableName : string
-
the name of the table whose primary key sequence will be reset
- $value : mixed = null
-
the value for the primary key of the next new row inserted. If this is not set, the next new row's primary key will have a value 1.
Tags
Return values
string —the SQL statement for resetting sequence
selectExists()
Creates a SELECT EXISTS() SQL statement.
public
selectExists(mixed $rawSql) : string
Parameters
- $rawSql : mixed
-
the subquery in a raw form to select from.
Tags
Return values
string —the SELECT EXISTS() SQL statement.
setConditionClasses()
Setter for [[conditionClasses]] property.
public
setConditionClasses(array<string|int, string> $classes) : mixed
Parameters
- $classes : array<string|int, string>
-
map of condition aliases to condition classes. For example:
['LIKE' => yii\db\condition\LikeCondition::class]
Tags
setExpressionBuilders()
Setter for [[expressionBuilders]] property.
public
setExpressionBuilders(array<string|int, string> $builders) : mixed
Parameters
- $builders : array<string|int, string>
-
array of builders that should be merged with the pre-defined ones in [[expressionBuilders]] property.
Tags
truncateTable()
Builds a SQL statement for truncating a DB table.
public
truncateTable(string $table) : string
Parameters
- $table : string
-
the table to be truncated. The name will be properly quoted by the method.
Return values
string —the SQL statement for truncating a DB table.
update()
Creates an UPDATE SQL statement.
public
update(string $table, array<string|int, mixed> $columns, array<string|int, mixed>|string $condition, array<string|int, mixed> &$params) : string
For example,
$params = [];
$sql = $queryBuilder->update('user', ['status' => 1], 'age > 30', $params);
The method will properly escape the table and column names.
Parameters
- $table : string
-
the table to be updated.
- $columns : array<string|int, mixed>
-
the column data (name => value) to be updated.
- $condition : array<string|int, mixed>|string
-
the condition that will be put in the WHERE part. Please refer to [[Query::where()]] on how to specify condition.
- $params : array<string|int, mixed>
-
the binding parameters that will be modified by this method so that they can be bound to the DB command later.
Return values
string —the UPDATE SQL
upsert()
Creates an SQL statement to insert rows into a database table if they do not already exist (matching unique constraints), or update them if they do.
public
upsert(mixed $table, mixed $insertColumns, mixed $updateColumns, mixed &$params) : string
Parameters
- $table : mixed
-
the table that new rows will be inserted into/updated in.
- $insertColumns : mixed
-
the column data (name => value) to be inserted into the table or instance of [[Query]] to perform
INSERT INTO ... SELECT
SQL statement. - $updateColumns : mixed
-
the column data (name => value) to be updated if they already exist. If
true
is passed, the column data will be updated to match the insert column data. Iffalse
is passed, no update will be performed if the column data already exists. - $params : mixed
-
the binding parameters that will be generated by this method. They should be bound to the DB command later.
Tags
Return values
string —the resulting SQL.
defaultConditionClasses()
Contains array of default condition classes. Extend this method, if you want to change default condition classes for the query builder. See [[conditionClasses]] docs for details.
protected
defaultConditionClasses() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>defaultExpressionBuilders()
Contains array of default expression builders. Extend this method and override it, if you want to change default expression builders for this query builder. See [[expressionBuilders]] docs for details.
protected
defaultExpressionBuilders() : array<string|int, mixed>
Return values
array<string|int, mixed>extractAlias()
Extracts table alias if there is one or returns false
protected
extractAlias(mixed $table) : bool|array<string|int, mixed>
Parameters
- $table : mixed
Tags
Return values
bool|array<string|int, mixed>hasLimit()
Checks to see if the given limit is effective.
protected
hasLimit(mixed $limit) : bool
Parameters
- $limit : mixed
-
the given limit
Return values
bool —whether the limit is effective
hasOffset()
Checks to see if the given offset is effective.
protected
hasOffset(mixed $offset) : bool
Parameters
- $offset : mixed
-
the given offset
Return values
bool —whether the offset is effective
prepareInsertSelectSubQuery()
Prepare select-subquery and field names for INSERT INTO ... SELECT SQL statement.
protected
prepareInsertSelectSubQuery(Query $columns, Schema $schema[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $columns : Query
-
Object, which represents select query.
- $schema : Schema
-
Schema object to quote column name.
- $params : array<string|int, mixed> = []
-
the parameters to be bound to the generated SQL statement. These parameters will be included in the result with the additional parameters generated during the query building process.
Tags
Return values
array<string|int, mixed> —array of column names, values and params.
prepareInsertValues()
Prepares a `VALUES` part for an `INSERT` SQL statement.
protected
prepareInsertValues(string $table, array<string|int, mixed>|Query $columns[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $table : string
-
the table that new rows will be inserted into.
- $columns : array<string|int, mixed>|Query
-
the column data (name => value) to be inserted into the table or instance of [[yii\db\Query|Query]] to perform INSERT INTO ... SELECT SQL statement.
- $params : array<string|int, mixed> = []
-
the binding parameters that will be generated by this method. They should be bound to the DB command later.
Tags
Return values
array<string|int, mixed> —array of column names, placeholders, values and params.
prepareUpdateSets()
Prepares a `SET` parts for an `UPDATE` SQL statement.
protected
prepareUpdateSets(string $table, array<string|int, mixed> $columns[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $table : string
-
the table to be updated.
- $columns : array<string|int, mixed>
-
the column data (name => value) to be updated.
- $params : array<string|int, mixed> = []
-
the binding parameters that will be modified by this method so that they can be bound to the DB command later.
Tags
Return values
array<string|int, mixed> —an array SET
parts for an UPDATE
SQL statement (the first array element) and params (the second array element).
prepareUpsertColumns()
protected
prepareUpsertColumns(string $table, array<string|int, mixed>|Query $insertColumns, array<string|int, mixed>|bool $updateColumns[, array<string|int, Constraint> &$constraints = [] ]) : array<string|int, mixed>
Parameters
- $table : string
- $insertColumns : array<string|int, mixed>|Query
- $updateColumns : array<string|int, mixed>|bool
- $constraints : array<string|int, Constraint> = []
-
this parameter recieves a matched constraint list. The constraints will be unique by their column names.
Tags
Return values
array<string|int, mixed>getColumnDefinition()
Gets column definition.
private
getColumnDefinition(string $table, string $column) : string|null
Parameters
- $table : string
-
table name
- $column : string
-
column name
Tags
Return values
string|null —the column definition
getTableUniqueColumnNames()
Returns all column names belonging to constraints enforcing uniqueness (`PRIMARY KEY`, `UNIQUE INDEX`, etc.) for the named table removing constraints which did not cover the specified column list.
private
getTableUniqueColumnNames(string $name, array<string|int, string> $columns[, array<string|int, Constraint> &$constraints = [] ]) : array<string|int, string>
The column list will be unique by column names.
Parameters
- $name : string
-
table name. The table name may contain schema name if any. Do not quote the table name.
- $columns : array<string|int, string>
-
source column list.
- $constraints : array<string|int, Constraint> = []
-
this parameter optionally recieves a matched constraint list. The constraints will be unique by their column names.
Return values
array<string|int, string> —column list.
quoteTableNames()
Quotes table names passed.
private
quoteTableNames(array<string|int, mixed> $tables, array<string|int, mixed> &$params) : array<string|int, mixed>
Parameters
- $tables : array<string|int, mixed>
- $params : array<string|int, mixed>