A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.yiiframework.com/doc/api/2.0/yii-db-schemabuildertrait below:

SchemaBuilderTrait, yii\db\SchemaBuilderTrait | API Documentation for Yii 2.0

Trait yii\db\SchemaBuilderTrait

SchemaBuilderTrait contains shortcut methods to create instances of yii\db\ColumnSchemaBuilder.

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:

$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(),
]);
Method Details

Hide inherited methods

Creates a bigint column.

Source code

                public function bigInteger($length = null)
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_BIGINT, $length);
}

            

Creates a big primary key column.

Source code

                public function bigPrimaryKey($length = null)
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_BIGPK, $length);
}

            

Creates a binary column.

Source code

                public function binary($length = null)
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_BINARY, $length);
}

            

Creates a boolean column.

Source code

                public function boolean()
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_BOOLEAN);
}

            

Creates a char column.

Source code

                public function char($length = null)
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_CHAR, $length);
}

            

Creates a date column.

Source code

                public function date()
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_DATE);
}

            

Creates a datetime column.

Source code

                public function dateTime($precision = null)
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_DATETIME, $precision);
}

            

Creates a decimal column.

public yii\db\ColumnSchemaBuilder decimal ( $precision null, $scale null ) $precision integer|null

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|null

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.

return yii\db\ColumnSchemaBuilder

The column instance which can be further customized.

Source code

                public function decimal($precision = null, $scale = null)
{
    $length = [];
    if ($precision !== null) {
        $length[] = $precision;
    }
    if ($scale !== null) {
        $length[] = $scale;
    }
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_DECIMAL, $length);
}

            

Creates a double column.

Source code

                public function double($precision = null)
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_DOUBLE, $precision);
}

            

Creates a float column.

Source code

                public function float($precision = null)
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_FLOAT, $precision);
}

            

Creates an integer column.

Source code

                public function integer($length = null)
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_INTEGER, $length);
}

            

Creates a JSON column.

Source code

                public function json()
{
    
    if (version_compare(PHP_VERSION, '5.6', '<') && $this->getDb()->getDriverName() === 'mysql') {
        throw new \yii\base\Exception('JSON column type is not supported in PHP < 5.6');
    }
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_JSON);
}

            

Creates a money column.

public yii\db\ColumnSchemaBuilder money ( $precision null, $scale null ) $precision integer|null

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|null

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.

return yii\db\ColumnSchemaBuilder

The column instance which can be further customized.

Source code

                public function money($precision = null, $scale = null)
{
    $length = [];
    if ($precision !== null) {
        $length[] = $precision;
    }
    if ($scale !== null) {
        $length[] = $scale;
    }
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_MONEY, $length);
}

            

Creates a primary key column.

Source code

                public function primaryKey($length = null)
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_PK, $length);
}

            

Creates a smallint column.

Source code

                public function smallInteger($length = null)
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_SMALLINT, $length);
}

            

Creates a string column.

Source code

                public function string($length = null)
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_STRING, $length);
}

            

Creates a text column.

Source code

                public function text()
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_TEXT);
}

            

Creates a time column.

Source code

                public function time($precision = null)
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_TIME, $precision);
}

            

Creates a timestamp column.

Source code

                public function timestamp($precision = null)
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_TIMESTAMP, $precision);
}

            

Creates a tinyint column. If tinyint is not supported by the DBMS, smallint will be used.

Source code

                public function tinyInteger($length = null)
{
    return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_TINYINT, $length);
}

            

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4