Class yii\db\mssql\QueryBuilder
Inheritance | yii\db\mssql\QueryBuilder » yii\db\QueryBuilder » yii\base\Object |
---|---|
Implements | yii\base\Configurable |
Available since version | 2.0 |
Source Code | https://github.com/yiisoft/yii2/blob/master/framework/db/mssql/QueryBuilder.php |
QueryBuilder is the query builder for MS SQL Server databases (version 2008 and above).
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$db | yii\db\Connection | The database connection. | yii\db\QueryBuilder |
$separator | string | The separator between different fragments of a SQL statement. | yii\db\QueryBuilder |
$typeMap | array | Mapping from abstract column types (keys) to physical column types (values). | yii\db\mssql\QueryBuilder |
Protected Properties
Property | Type | Description | Defined By |
---|---|---|---|
$conditionBuilders | array | Map of query condition to builder methods. | yii\db\QueryBuilder |
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\Object |
__construct() | Constructor. | yii\db\QueryBuilder |
__get() | Returns the value of an object property. | yii\base\Object |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\Object |
__set() | Sets value of an object property. | yii\base\Object |
__unset() | Sets an object property to null. | yii\base\Object |
addColumn() | Builds a SQL statement for adding a new DB column. | yii\db\QueryBuilder |
addForeignKey() | Builds a SQL statement for adding a foreign key constraint to an existing table. | yii\db\QueryBuilder |
addPrimaryKey() | Builds a SQL statement for adding a primary key constraint to an existing table. | yii\db\QueryBuilder |
alterColumn() | Builds a SQL statement for changing the definition of a column. | yii\db\mssql\QueryBuilder |
batchInsert() | Generates a batch INSERT SQL statement. | yii\db\QueryBuilder |
build() | Generates a SELECT SQL statement from a yii\db\Query object. | yii\db\QueryBuilder |
buildAndCondition() | Connects two or more SQL expressions with the AND or OR operator. |
yii\db\QueryBuilder |
buildBetweenCondition() | Creates an SQL expressions with the BETWEEN operator. |
yii\db\QueryBuilder |
buildColumns() | Processes columns and properly quotes them if necessary. | yii\db\QueryBuilder |
buildCondition() | Parses the condition specification and generates the corresponding SQL expression. | yii\db\QueryBuilder |
buildExistsCondition() | Creates an SQL expressions with the EXISTS operator. |
yii\db\QueryBuilder |
buildFrom() | yii\db\QueryBuilder | |
buildGroupBy() | yii\db\QueryBuilder | |
buildHashCondition() | Creates a condition based on column-value pairs. | yii\db\QueryBuilder |
buildHaving() | yii\db\QueryBuilder | |
buildInCondition() | Creates an SQL expressions with the IN operator. |
yii\db\QueryBuilder |
buildJoin() | yii\db\QueryBuilder | |
buildLikeCondition() | Creates an SQL expressions with the LIKE operator. |
yii\db\QueryBuilder |
buildLimit() | yii\db\QueryBuilder | |
buildNotCondition() | Inverts an SQL expressions with NOT operator. |
yii\db\QueryBuilder |
buildOrderBy() | yii\db\QueryBuilder | |
buildOrderByAndLimit() | Builds the ORDER BY and LIMIT/OFFSET clauses and appends them to the given SQL. | yii\db\mssql\QueryBuilder |
buildSelect() | yii\db\QueryBuilder | |
buildSimpleCondition() | Creates an SQL expressions like "column" operator value . |
yii\db\QueryBuilder |
buildUnion() | yii\db\QueryBuilder | |
buildWhere() | yii\db\QueryBuilder | |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\Object |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\Object |
checkIntegrity() | Builds a SQL statement for enabling or disabling integrity check. | yii\db\mssql\QueryBuilder |
className() | Returns the fully qualified name of this class. | yii\base\Object |
createIndex() | Builds a SQL statement for creating a new index. | yii\db\QueryBuilder |
createTable() | Builds a SQL statement for creating a new DB table. | yii\db\QueryBuilder |
delete() | Creates a DELETE SQL statement. | yii\db\QueryBuilder |
dropColumn() | Builds a SQL statement for dropping a DB column. | yii\db\QueryBuilder |
dropForeignKey() | Builds a SQL statement for dropping a foreign key constraint. | yii\db\QueryBuilder |
dropIndex() | Builds a SQL statement for dropping an index. | yii\db\QueryBuilder |
dropPrimaryKey() | Builds a SQL statement for removing a primary key constraint to an existing table. | yii\db\QueryBuilder |
dropTable() | Builds a SQL statement for dropping a DB table. | yii\db\QueryBuilder |
getColumnType() | Converts an abstract column type into a physical column type. | yii\db\QueryBuilder |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\Object |
hasProperty() | Returns a value indicating whether a property is defined. | yii\base\Object |
init() | Initializes the object. | yii\base\Object |
insert() | Creates an INSERT SQL statement. | yii\db\QueryBuilder |
renameColumn() | Builds a SQL statement for renaming a column. | yii\db\mssql\QueryBuilder |
renameTable() | Builds a SQL statement for renaming a DB table. | yii\db\mssql\QueryBuilder |
resetSequence() | Creates a SQL statement for resetting the sequence value of a table's primary key. | yii\db\QueryBuilder |
truncateTable() | Builds a SQL statement for truncating a DB table. | yii\db\QueryBuilder |
update() | Creates an UPDATE SQL statement. | yii\db\QueryBuilder |
Protected Methods
Method | Description | Defined By |
---|---|---|
buildCompositeInCondition() | Builds SQL for IN condition | yii\db\mssql\QueryBuilder |
buildSubqueryInCondition() | Builds SQL for IN condition | yii\db\mssql\QueryBuilder |
getAllColumnNames() | Returns an array of column names given model name | yii\db\mssql\QueryBuilder |
hasLimit() | Checks to see if the given limit is effective. | yii\db\QueryBuilder |
hasOffset() | Checks to see if the given offset is effective. | yii\db\QueryBuilder |
isOldMssql() | yii\db\mssql\QueryBuilder | |
newBuildOrderByAndLimit() | Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2012 or newer. | yii\db\mssql\QueryBuilder |
oldBuildOrderByAndLimit() | Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2005 to 2008. | yii\db\mssql\QueryBuilder |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
PARAM_PREFIX | ':qp' | The prefix for automatically generated query binding parameters. | yii\db\QueryBuilder |
Property Details
Mapping from abstract column types (keys) to physical column types (values).
Method Details
Builds a SQL statement for changing the definition of a column.
string alterColumn( $table, $column, $type ) | ||
$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 | string | The SQL statement for changing the definition of a column. |
---|
Builds SQL for IN condition
string buildCompositeInCondition( $operator, $columns, $values, <b>&</b>$params ) | ||
$operator | string | |
$columns | array | |
$values | array | |
$params | array | |
return | string | SQL |
---|
Builds the ORDER BY and LIMIT/OFFSET clauses and appends them to the given SQL.
string buildOrderByAndLimit( $sql, $orderBy, $limit, $offset ) | ||
$sql | string | The existing SQL (without ORDER BY/LIMIT/OFFSET) |
$orderBy | array | The order by columns. See yii\db\Query::orderBy() for more details on how to specify this parameter. |
$limit | integer | The limit number. See yii\db\Query::limit() for more details. |
$offset | integer | The offset number. See yii\db\Query::offset() for more details. |
return | string | The SQL completed with ORDER BY/LIMIT/OFFSET (if any) |
---|
Builds SQL for IN condition
string buildSubqueryInCondition( $operator, $columns, $values, <b>&</b>$params ) | ||
$operator | string | |
$columns | array | |
$values | yii\db\Query | |
$params | array | |
return | string | SQL |
---|
Builds a SQL statement for enabling or disabling integrity check.
string checkIntegrity( $check = true, $schema = '', $table = '' ) | ||
$check | boolean | 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. |
return | string | The SQL statement for checking integrity |
---|---|---|
throws | yii\base\InvalidParamException | if the table does not exist or there is no sequence associated with the table. |
Returns an array of column names given model name
array|null getAllColumnNames( $modelClass = null ) | ||
$modelClass | string | Name of the model class |
return | array|null | Array of column names |
---|
boolean isOldMssql( ) | ||
return | boolean | Whether the version of the MSSQL being used is older than 2012. |
---|---|---|
throws | yii\base\InvalidConfigException | |
throws | yii\db\Exception |
Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2012 or newer.
string newBuildOrderByAndLimit( $sql, $orderBy, $limit, $offset ) | ||
$sql | string | The existing SQL (without ORDER BY/LIMIT/OFFSET) |
$orderBy | array | The order by columns. See yii\db\Query::orderBy() for more details on how to specify this parameter. |
$limit | integer | The limit number. See yii\db\Query::limit() for more details. |
$offset | integer | The offset number. See yii\db\Query::offset() for more details. |
return | string | The SQL completed with ORDER BY/LIMIT/OFFSET (if any) |
---|
Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2005 to 2008.
string oldBuildOrderByAndLimit( $sql, $orderBy, $limit, $offset ) | ||
$sql | string | The existing SQL (without ORDER BY/LIMIT/OFFSET) |
$orderBy | array | The order by columns. See yii\db\Query::orderBy() for more details on how to specify this parameter. |
$limit | integer | The limit number. See yii\db\Query::limit() for more details. |
$offset | integer | The offset number. See yii\db\Query::offset() for more details. |
return | string | The SQL completed with ORDER BY/LIMIT/OFFSET (if any) |
---|
Builds a SQL statement for renaming a column.
string renameColumn( $table, $name, $newName ) | ||
$table | string | The table whose column is to be renamed. The name will be properly quoted by the method. |
$name | 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 | string | The SQL statement for renaming a DB column. |
---|
Builds a SQL statement for renaming a DB table.
string renameTable( $table, $newName ) | ||
$table | 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 | string | The SQL statement for renaming a DB table. |
---|