protected function _createColumn($Name, $Type, $Null, $Default, $KeyType)
{
$Length = '';
$Precision = '';
// Check to see if the type starts with a 'u' for unsigned.
if (is_string($Type) && strncasecmp($Type, 'u', 1) == 0) {
$Type = substr($Type, 1);
$Unsigned = true;
} else {
$Unsigned = false;
}
// Check for a length in the type.
if (is_string($Type) && preg_match('/(\\w+)\\s*\\(\\s*(\\d+)\\s*(?:,\\s*(\\d+)\\s*)?\\)/', $Type, $Matches)) {
$Type = $Matches[1];
$Length = $Matches[2];
if (count($Matches) >= 4) {
$Precision = $Matches[3];
}
}
$Column = new stdClass();
$Column->Name = $Name;
$Column->Type = is_array($Type) ? 'enum' : $Type;
$Column->Length = $Length;
$Column->Precision = $Precision;
$Column->Enum = is_array($Type) ? $Type : false;
$Column->AllowNull = $Null;
$Column->Default = $Default;
$Column->KeyType = $KeyType;
$Column->Unsigned = $Unsigned;
$Column->AutoIncrement = false;
// Handle enums and sets as types.
if (is_array($Type)) {
if (count($Type) === 2 && is_array(val(1, $Type))) {
// The type is specified as the first element in the array.
$Column->Type = $Type[0];
$Column->Enum = $Type[1];
} else {
// This is an enum.
$Column->Type = 'enum';
$Column->Enum = $Type;
}
} else {
$Column->Type = $Type;
$Column->Enum = false;
}
return $Column;
}