PHP Class yii\db\mssql\QueryBuilder

Since: 2.0
Author: Timur Ruziev ([email protected])
Inheritance: extends yii\db\QueryBuilder
Show file Open project: yiisoft/yii2

Public Properties

Property Type Description
$typeMap mapping from abstract column types (keys) to physical column types (values).

Public Methods

Method Description
addCommentOnColumn ( $table, $column, $comment )
addCommentOnTable ( $table, $comment )
alterColumn ( string $table, string $column, string $type ) : string Builds a SQL statement for changing the definition of a column.
buildOrderByAndLimit ( $sql, $orderBy, $limit, $offset )
checkIntegrity ( boolean $check = true, string $schema = '', string $table = '' ) : string Builds a SQL statement for enabling or disabling integrity check.
dropCommentFromColumn ( $table, $column )
dropCommentFromTable ( $table )
renameColumn ( string $table, string $oldName, string $newName ) : string Builds a SQL statement for renaming a column.
renameTable ( string $oldName, string $newName ) : string Builds a SQL statement for renaming a DB table.
selectExists ( $rawSql )

Protected Methods

Method Description
buildCompositeInCondition ( string $operator, array $columns, array $values, array &$params ) : string Builds SQL for IN condition
buildSubqueryInCondition ( $operator, $columns, $values, &$params )
getAllColumnNames ( string $modelClass = null ) : array | null Returns an array of column names given model name
isOldMssql ( ) : boolean
newBuildOrderByAndLimit ( string $sql, array $orderBy, integer $limit, integer $offset ) : string Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2012 or newer.
oldBuildOrderByAndLimit ( string $sql, array $orderBy, integer $limit, integer $offset ) : string Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2005 to 2008.

Method Details

addCommentOnColumn() public method

Since: 2.0.8
public addCommentOnColumn ( $table, $column, $comment )

addCommentOnTable() public method

Since: 2.0.8
public addCommentOnTable ( $table, $comment )

alterColumn() public method

Builds a SQL statement for changing the definition of a column.
public alterColumn ( string $table, string $column, string $type ) : string
$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.

buildCompositeInCondition() protected method

Builds SQL for IN condition
protected buildCompositeInCondition ( string $operator, array $columns, array $values, array &$params ) : string
$operator string
$columns array
$values array
$params array
return string SQL

buildOrderByAndLimit() public method

public buildOrderByAndLimit ( $sql, $orderBy, $limit, $offset )

buildSubqueryInCondition() protected method

protected buildSubqueryInCondition ( $operator, $columns, $values, &$params )

checkIntegrity() public method

Builds a SQL statement for enabling or disabling integrity check.
public checkIntegrity ( boolean $check = true, string $schema = '', string $table = '' ) : string
$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

dropCommentFromColumn() public method

Since: 2.0.8
public dropCommentFromColumn ( $table, $column )

dropCommentFromTable() public method

Since: 2.0.8
public dropCommentFromTable ( $table )

getAllColumnNames() protected method

Returns an array of column names given model name
protected getAllColumnNames ( string $modelClass = null ) : array | null
$modelClass string name of the model class
return array | null array of column names

isOldMssql() protected method

protected isOldMssql ( ) : boolean
return boolean whether the version of the MSSQL being used is older than 2012.

newBuildOrderByAndLimit() protected method

Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2012 or newer.
protected newBuildOrderByAndLimit ( string $sql, array $orderBy, integer $limit, integer $offset ) : string
$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)

oldBuildOrderByAndLimit() protected method

Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2005 to 2008.
protected oldBuildOrderByAndLimit ( string $sql, array $orderBy, integer $limit, integer $offset ) : string
$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)

renameColumn() public method

Builds a SQL statement for renaming a column.
public renameColumn ( string $table, string $oldName, string $newName ) : string
$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 string the SQL statement for renaming a DB column.

renameTable() public method

Builds a SQL statement for renaming a DB table.
public renameTable ( string $oldName, string $newName ) : string
$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 string the SQL statement for renaming a DB table.

selectExists() public method

Since: 2.0.8
public selectExists ( $rawSql )

Property Details

$typeMap public property

mapping from abstract column types (keys) to physical column types (values).
public $typeMap