PHP Трейт 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(), ]);
С версии: 2.0.6
Автор: Vasenin Matvey ([email protected])
Показать файл Открыть проект

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
getDb ( ) : Connection

Описание методов

bigInteger() публичный Метод

Creates a bigint column.
С версии: 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.
Результат ColumnSchemaBuilder the column instance which can be further customized.

bigPrimaryKey() публичный Метод

Creates a big primary key column.
С версии: 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.
Результат ColumnSchemaBuilder the column instance which can be further customized.

binary() публичный Метод

Creates a binary column.
С версии: 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.
Результат ColumnSchemaBuilder the column instance which can be further customized.

boolean() публичный Метод

Creates a boolean column.
С версии: 2.0.6
public boolean ( ) : ColumnSchemaBuilder
Результат ColumnSchemaBuilder the column instance which can be further customized.

char() публичный Метод

Creates a char column.
С версии: 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.
Результат ColumnSchemaBuilder the column instance which can be further customized.

date() публичный Метод

Creates a date column.
С версии: 2.0.6
public date ( ) : ColumnSchemaBuilder
Результат ColumnSchemaBuilder the column instance which can be further customized.

dateTime() публичный Метод

Creates a datetime column.
С версии: 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.
Результат ColumnSchemaBuilder the column instance which can be further customized.

decimal() публичный Метод

Creates a decimal column.
С версии: 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.
Результат ColumnSchemaBuilder the column instance which can be further customized.

double() публичный Метод

Creates a double column.
С версии: 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.
Результат ColumnSchemaBuilder the column instance which can be further customized.

float() публичный Метод

Creates a float column.
С версии: 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.
Результат ColumnSchemaBuilder the column instance which can be further customized.

getDb() абстрактный защищенный Метод

abstract protected getDb ( ) : Connection
Результат Connection the database connection to be used for schema building.

integer() публичный Метод

Creates an integer column.
С версии: 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.
Результат ColumnSchemaBuilder the column instance which can be further customized.

money() публичный Метод

Creates a money column.
С версии: 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.
Результат ColumnSchemaBuilder the column instance which can be further customized.

primaryKey() публичный Метод

Creates a primary key column.
С версии: 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.
Результат ColumnSchemaBuilder the column instance which can be further customized.

smallInteger() публичный Метод

Creates a smallint column.
С версии: 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.
Результат ColumnSchemaBuilder the column instance which can be further customized.

string() публичный Метод

Creates a string column.
С версии: 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.
Результат ColumnSchemaBuilder the column instance which can be further customized.

text() публичный Метод

Creates a text column.
С версии: 2.0.6
public text ( ) : ColumnSchemaBuilder
Результат ColumnSchemaBuilder the column instance which can be further customized.

time() публичный Метод

Creates a time column.
С версии: 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.
Результат ColumnSchemaBuilder the column instance which can be further customized.

timestamp() публичный Метод

Creates a timestamp column.
С версии: 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.
Результат ColumnSchemaBuilder the column instance which can be further customized.