yii\db\SchemaBuilderTrait::decimal PHP Method

decimal() public method

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.
return ColumnSchemaBuilder the column instance which can be further customized.
    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);
    }