Gdn_DatabaseStructure::types PHP Method

types() public method

Gets an array of type names allowed in the structure.
public types ( string $Class = 'all' )
$Class string The class of types to get. Valid values are: - int: Integer types. - float: Floating point types. - decimal: Precise decimal types. - numeric: float, int and decimal. - string: String types. - date: Date types. - length: Types that have a length. - precision: Types that have a precision. - other: Types that don't fit into any other category on their own. - all: All recognized types.
    public function types($Class = 'all')
    {
        $Date = array('datetime', 'date', 'timestamp');
        $Decimal = array('decimal', 'numeric');
        $Float = array('float', 'double');
        $Int = array('int', 'tinyint', 'smallint', 'mediumint', 'bigint');
        $String = array('varchar', 'char', 'mediumtext', 'text');
        $Length = array('varbinary');
        $Other = array('enum', 'tinyblob', 'blob', 'mediumblob', 'longblob', 'ipaddress');
        switch (strtolower($Class)) {
            case 'date':
                return $Date;
            case 'decimal':
                return $Decimal;
            case 'float':
                return $Float;
            case 'int':
                return $Int;
            case 'string':
                return $String;
            case 'other':
                return array_merge($Length, $Other);
            case 'numeric':
                return array_merge($Float, $Int, $Decimal);
            case 'length':
                return array_merge($String, $Length, $Decimal);
            case 'precision':
                return $Decimal;
            default:
                return array();
        }
    }