classes/MigrationColumnType.php
public static function lengthToPrecisionAndScale($type, $length)
    {
        $length = trim($length);

        if (!strlen($length)) {
            return [];
        }

        $result = [
            'length' => null,
            'precision' => null,
            'scale' => null
        ];

        if (in_array($type, self::getDecimalTypes())) {
            $matches = [];

            if (!preg_match(self::REGEX_LENGTH_DOUBLE, $length, $matches)) {
                throw new ApplicationException(Lang::get('rainlab.builder::lang.database.error_table_length', [
                    'type' => $type
                ]));
            }

            $result['precision'] = $matches[1];
            $result['scale'] = $matches[2];

            return $result;
        }

        if (in_array($type, self::getIntegerTypes())) {
            if (!preg_match(self::REGEX_LENGTH_SINGLE, $length)) {
                throw new ApplicationException(Lang::get('rainlab.builder::lang.database.error_table_length', [
                    'type' => $type
                ]));
            }

            $result['precision'] = $length;
            $result['scale'] = 0;

            return $result;
        }

        $result['length'] = $length;
        return $result;
    }
public static function lengthToPrecisionAndScale($type, $length)
    {
        $length = trim($length);

        if (!strlen($length)) {
            return [];
        }

        $result = [
            'length' => null,
            'precision' => null,
            'scale' => null
        ];

        if (in_array($type, self::getDecimalTypes())) {
            $matches = [];

            if (!preg_match(self::REGEX_LENGTH_DOUBLE, $length, $matches)) {
                throw new ApplicationException(Lang::get('rainlab.builder::lang.database.error_table_length', [
                    'type' => $type
                ]));
            }

            $result['precision'] = $matches[1];
            $result['scale'] = $matches[2];

            return $result;
        }

        if (in_array($type, self::getIntegerTypes())) {
            if (!preg_match(self::REGEX_LENGTH_SINGLE, $length)) {
                throw new ApplicationException(Lang::get('rainlab.builder::lang.database.error_table_length', [
                    'type' => $type
                ]));
            }

            $result['precision'] = $length;
            $result['scale'] = 0;

            return $result;
        }

        $result['length'] = $length;
        return $result;
    }
public static function lengthToPrecisionAndScale ( $ type , $ length ) { $ length = trim ( $ length ) ; if ( ! strlen ( $ length ) ) { return [ ] ; } $ result = [ 'length' => null , 'precision' => null , 'scale' => null ] ; if ( in_array ( $ type , self :: getDecimalTypes ( ) ) ) { $ matches = [ ] ; if ( ! preg_match ( self :: REGEX_LENGTH_DOUBLE , $ length , $ matches ) ) { throw new ApplicationException ( Lang :: get ( 'rainlab.builder::lang.database.error_table_length' , [ 'type' => $ type ] ) ) ; } $ result [ 'precision' ] = $ matches [ 1 ] ; $ result [ 'scale' ] = $ matches [ 2 ] ; return $ result ; } if ( in_array ( $ type , self :: getIntegerTypes ( ) ) ) { if ( ! preg_match ( self :: REGEX_LENGTH_SINGLE , $ length ) ) { throw new ApplicationException ( Lang :: get ( 'rainlab.builder::lang.database.error_table_length' , [ 'type' => $ type ] ) ) ; } $ result [ 'precision' ] = $ length ; $ result [ 'scale' ] = 0 ; return $ result ; } $ result [ 'length' ] = $ length ; return $ result ; }
Returns an array containing a column length, precision and scale, basing on the column type.
Returns an array containing a column length precision and scale basing on the column type .