Gdn_DatabaseStructure::columnTypeString PHP Method

columnTypeString() public method

Return the definition string for a column.
public columnTypeString ( mixed $Column ) : string
$Column mixed The column to get the type string from. - object: The column as returned by the database schema. The properties looked at are Type, Length, and Precision. - string
return string The type definition string.
    public function columnTypeString($Column)
    {
        if (is_string($Column)) {
            $Column = $this->_Columns[$Column];
        }
        $Type = val('Type', $Column);
        $Length = val('Length', $Column);
        $Precision = val('Precision', $Column);
        if (in_array(strtolower($Type), array('tinyint', 'smallint', 'mediumint', 'int', 'float', 'double'))) {
            $Length = null;
        }
        if ($Type && $Length && $Precision) {
            $Result = "{$Type}({$Length}, {$Precision})";
        } elseif ($Type && $Length) {
            $Result = "{$Type}({$Length})";
        } elseif (strtolower($Type) == 'enum') {
            $Result = val('Enum', $Column, array());
        } elseif ($Type) {
            $Result = $Type;
        } else {
            $Result = 'int';
        }
        return $Result;
    }