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])
파일 보기 프로젝트 열기: yiisoft/yii2

공개 메소드들

메소드 설명
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.