PHP Class yii\db\sqlite\QueryBuilder

Since: 2.0
Author: Qiang Xue ([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 )
addForeignKey ( string $name, string $table, string | array $columns, string $refTable, string | array $refColumns, string $delete = null, string $update = null ) : string Builds a SQL statement for adding a foreign key constraint to an existing table.
addPrimaryKey ( string $name, string $table, string | array $columns ) : string Builds a SQL statement for adding a primary key constraint to an existing table.
alterColumn ( string $table, string $column, string $type ) : string Builds a SQL statement for changing the definition of a column.
batchInsert ( string $table, array $columns, array $rows ) : string Generates a batch INSERT SQL statement.
build ( $query, $params = [] )
buildLimit ( $limit, $offset )
buildUnion ( $unions, &$params )
checkIntegrity ( boolean $check = true, string $schema = '', string $table = '' ) : string Enables or disables integrity check.
dropColumn ( string $table, string $column ) : string Builds a SQL statement for dropping a DB column.
dropCommentFromColumn ( $table, $column )
dropCommentFromTable ( $table )
dropForeignKey ( string $name, string $table ) : string Builds a SQL statement for dropping a foreign key constraint.
dropIndex ( string $name, string $table ) : string Builds a SQL statement for dropping an index.
dropPrimaryKey ( string $name, string $table ) : string Builds a SQL statement for removing a primary key constraint to an existing table.
renameColumn ( string $table, string $oldName, string $newName ) : string Builds a SQL statement for renaming a column.
renameTable ( string $table, string $newName ) : string Builds a SQL statement for renaming a DB table.
resetSequence ( string $tableName, mixed $value = null ) : string Creates a SQL statement for resetting the sequence value of a table's primary key.
truncateTable ( string $table ) : string Builds a SQL statement for truncating a DB table.

Protected Methods

Method Description
buildCompositeInCondition ( string $operator, array $columns, array $values, array &$params ) : string Builds SQL for IN condition
buildSubqueryInCondition ( $operator, $columns, $values, &$params )

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 )

addForeignKey() public method

The method will properly quote the table and column names.
public addForeignKey ( string $name, string $table, string | array $columns, string $refTable, string | array $refColumns, string $delete = null, string $update = null ) : string
$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 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 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 the ON DELETE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
$update string the ON UPDATE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
return string the SQL statement for adding a foreign key constraint to an existing table.

addPrimaryKey() public method

Builds a SQL statement for adding a primary key constraint to an existing table.
public addPrimaryKey ( string $name, string $table, string | array $columns ) : string
$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 comma separated string or array of columns that the primary key will consist of.
return string the SQL statement for adding a primary key constraint to an existing table.

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.

batchInsert() public method

For example, php $connection->createCommand()->batchInsert('user', ['name', 'age'], [ ['Tom', 30], ['Jane', 20], ['Linda', 25], ])->execute(); Note that the values in each row must match the corresponding column names.
public batchInsert ( string $table, array $columns, array $rows ) : string
$table string the table that new rows will be inserted into.
$columns array the column names
$rows array the rows to be batch inserted into the table
return string the batch INSERT SQL statement

build() public method

public build ( $query, $params = [] )

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

buildLimit() public method

public buildLimit ( $limit, $offset )

buildSubqueryInCondition() protected method

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

buildUnion() public method

public buildUnion ( $unions, &$params )

checkIntegrity() public method

Enables or disables 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. Meaningless for SQLite.
$table string the table name. Meaningless for SQLite.
return string the SQL statement for checking integrity

dropColumn() public method

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

dropCommentFromColumn() public method

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

dropCommentFromTable() public method

Since: 2.0.8
public dropCommentFromTable ( $table )

dropForeignKey() public method

Builds a SQL statement for dropping a foreign key constraint.
public dropForeignKey ( string $name, string $table ) : string
$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 string the SQL statement for dropping a foreign key constraint.

dropIndex() public method

Builds a SQL statement for dropping an index.
public dropIndex ( string $name, string $table ) : string
$name string the name of the index to be dropped. The name will be properly quoted by the method.
$table string the table whose index is to be dropped. The name will be properly quoted by the method.
return string the SQL statement for dropping an index.

dropPrimaryKey() public method

Builds a SQL statement for removing a primary key constraint to an existing table.
public dropPrimaryKey ( string $name, string $table ) : string
$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 string the SQL statement for removing a primary key constraint from an existing table.

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 $table, string $newName ) : string
$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.

resetSequence() public method

The sequence will be reset such that the primary key of the next new row inserted will have the specified value or 1.
public resetSequence ( string $tableName, mixed $value = null ) : string
$tableName string the name of the table whose primary key sequence will be reset
$value mixed 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.
return string the SQL statement for resetting sequence

truncateTable() public method

Builds a SQL statement for truncating a DB table.
public truncateTable ( string $table ) : string
$table string the table to be truncated. The name will be properly quoted by the method.
return string the SQL statement for truncating a DB table.

Property Details

$typeMap public property

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