PHP Trait yii\db\SchemaBuilderTrait

These can be used in database migrations to define database schema types using a PHP interface. This is useful to define a schema in a DBMS independent way so that the application may run on different DBMS the same way. For example you may use the following code inside your migration files: php $this->createTable('example_table', [ 'id' => $this->primaryKey(), 'name' => $this->string(64)->notNull(), 'type' => $this->integer()->notNull()->defaultValue(10), 'description' => $this->text(), 'rule_name' => $this->string(64), 'data' => $this->text(), 'created_at' => $this->datetime()->notNull(), 'updated_at' => $this->datetime(), ]);
Since: 2.0.6
Author: Vasenin Matvey ([email protected])
Afficher le fichier Open project: yiisoft/yii2

Méthodes publiques

Méthode Description
bigInteger ( integer $length = null ) : ColumnSchemaBuilder Creates a bigint column.
bigPrimaryKey ( integer $length = null ) : ColumnSchemaBuilder Creates a big primary key column.
binary ( integer $length = null ) : ColumnSchemaBuilder Creates a binary column.
boolean ( ) : ColumnSchemaBuilder Creates a boolean column.
char ( integer $length = null ) : ColumnSchemaBuilder Creates a char column.
date ( ) : ColumnSchemaBuilder Creates a date column.
dateTime ( integer $precision = null ) : ColumnSchemaBuilder Creates a datetime column.
decimal ( integer $precision = null, integer $scale = null ) : ColumnSchemaBuilder Creates a decimal column.
double ( integer $precision = null ) : ColumnSchemaBuilder Creates a double column.
float ( integer $precision = null ) : ColumnSchemaBuilder Creates a float column.
integer ( integer $length = null ) : ColumnSchemaBuilder Creates an integer column.
money ( integer $precision = null, integer $scale = null ) : ColumnSchemaBuilder Creates a money column.
primaryKey ( integer $length = null ) : ColumnSchemaBuilder Creates a primary key column.
smallInteger ( integer $length = null ) : ColumnSchemaBuilder Creates a smallint column.
string ( integer $length = null ) : ColumnSchemaBuilder Creates a string column.
text ( ) : ColumnSchemaBuilder Creates a text column.
time ( integer $precision = null ) : ColumnSchemaBuilder Creates a time column.
timestamp ( integer $precision = null ) : ColumnSchemaBuilder Creates a timestamp column.

Méthodes protégées

Méthode Description
getDb ( ) : Connection

Method Details

bigInteger() public méthode

Creates a bigint column.
Since: 2.0.6
public bigInteger ( integer $length = null ) : ColumnSchemaBuilder
$length integer column size or precision definition. This parameter will be ignored if not supported by the DBMS.
Résultat ColumnSchemaBuilder the column instance which can be further customized.

bigPrimaryKey() public méthode

Creates a big primary key column.
Since: 2.0.6
public bigPrimaryKey ( integer $length = null ) : ColumnSchemaBuilder
$length integer column size or precision definition. This parameter will be ignored if not supported by the DBMS.
Résultat ColumnSchemaBuilder the column instance which can be further customized.

binary() public méthode

Creates a binary column.
Since: 2.0.6
public binary ( integer $length = null ) : ColumnSchemaBuilder
$length integer column size or precision definition. This parameter will be ignored if not supported by the DBMS.
Résultat ColumnSchemaBuilder the column instance which can be further customized.

boolean() public méthode

Creates a boolean column.
Since: 2.0.6
public boolean ( ) : ColumnSchemaBuilder
Résultat ColumnSchemaBuilder the column instance which can be further customized.

char() public méthode

Creates a char column.
Since: 2.0.8
public char ( integer $length = null ) : ColumnSchemaBuilder
$length integer column size definition i.e. the maximum string length. This parameter will be ignored if not supported by the DBMS.
Résultat ColumnSchemaBuilder the column instance which can be further customized.

date() public méthode

Creates a date column.
Since: 2.0.6
public date ( ) : ColumnSchemaBuilder
Résultat ColumnSchemaBuilder the column instance which can be further customized.

dateTime() public méthode

Creates a datetime column.
Since: 2.0.6
public dateTime ( integer $precision = null ) : ColumnSchemaBuilder
$precision integer column value precision. First parameter passed to the column type, e.g. DATETIME(precision). This parameter will be ignored if not supported by the DBMS.
Résultat ColumnSchemaBuilder the column instance which can be further customized.

decimal() public méthode

Creates a decimal column.
Since: 2.0.6
public decimal ( integer $precision = null, integer $scale = null ) : ColumnSchemaBuilder
$precision integer column value precision, which is usually the total number of digits. First parameter passed to the column type, e.g. DECIMAL(precision, scale). This parameter will be ignored if not supported by the DBMS.
$scale integer column value scale, which is usually the number of digits after the decimal point. Second parameter passed to the column type, e.g. DECIMAL(precision, scale). This parameter will be ignored if not supported by the DBMS.
Résultat ColumnSchemaBuilder the column instance which can be further customized.

double() public méthode

Creates a double column.
Since: 2.0.6
public double ( integer $precision = null ) : ColumnSchemaBuilder
$precision integer column value precision. First parameter passed to the column type, e.g. DOUBLE(precision). This parameter will be ignored if not supported by the DBMS.
Résultat ColumnSchemaBuilder the column instance which can be further customized.

float() public méthode

Creates a float column.
Since: 2.0.6
public float ( integer $precision = null ) : ColumnSchemaBuilder
$precision integer column value precision. First parameter passed to the column type, e.g. FLOAT(precision). This parameter will be ignored if not supported by the DBMS.
Résultat ColumnSchemaBuilder the column instance which can be further customized.

getDb() abstract protected méthode

abstract protected getDb ( ) : Connection
Résultat Connection the database connection to be used for schema building.

integer() public méthode

Creates an integer column.
Since: 2.0.6
public integer ( integer $length = null ) : ColumnSchemaBuilder
$length integer column size or precision definition. This parameter will be ignored if not supported by the DBMS.
Résultat ColumnSchemaBuilder the column instance which can be further customized.

money() public méthode

Creates a money column.
Since: 2.0.6
public money ( integer $precision = null, integer $scale = null ) : ColumnSchemaBuilder
$precision integer column value precision, which is usually the total number of digits. First parameter passed to the column type, e.g. DECIMAL(precision, scale). This parameter will be ignored if not supported by the DBMS.
$scale integer column value scale, which is usually the number of digits after the decimal point. Second parameter passed to the column type, e.g. DECIMAL(precision, scale). This parameter will be ignored if not supported by the DBMS.
Résultat ColumnSchemaBuilder the column instance which can be further customized.

primaryKey() public méthode

Creates a primary key column.
Since: 2.0.6
public primaryKey ( integer $length = null ) : ColumnSchemaBuilder
$length integer column size or precision definition. This parameter will be ignored if not supported by the DBMS.
Résultat ColumnSchemaBuilder the column instance which can be further customized.

smallInteger() public méthode

Creates a smallint column.
Since: 2.0.6
public smallInteger ( integer $length = null ) : ColumnSchemaBuilder
$length integer column size or precision definition. This parameter will be ignored if not supported by the DBMS.
Résultat ColumnSchemaBuilder the column instance which can be further customized.

string() public méthode

Creates a string column.
Since: 2.0.6
public string ( integer $length = null ) : ColumnSchemaBuilder
$length integer column size definition i.e. the maximum string length. This parameter will be ignored if not supported by the DBMS.
Résultat ColumnSchemaBuilder the column instance which can be further customized.

text() public méthode

Creates a text column.
Since: 2.0.6
public text ( ) : ColumnSchemaBuilder
Résultat ColumnSchemaBuilder the column instance which can be further customized.

time() public méthode

Creates a time column.
Since: 2.0.6
public time ( integer $precision = null ) : ColumnSchemaBuilder
$precision integer column value precision. First parameter passed to the column type, e.g. TIME(precision). This parameter will be ignored if not supported by the DBMS.
Résultat ColumnSchemaBuilder the column instance which can be further customized.

timestamp() public méthode

Creates a timestamp column.
Since: 2.0.6
public timestamp ( integer $precision = null ) : ColumnSchemaBuilder
$precision integer column value precision. First parameter passed to the column type, e.g. TIMESTAMP(precision). This parameter will be ignored if not supported by the DBMS.
Résultat ColumnSchemaBuilder the column instance which can be further customized.