function sqlColumna($columna) { $cadena = " "; $cadena .= $columna->name; $cadena .= sqlDato($columna->tipoDato); if (!$columna->isNull) { $cadena .= " NOT NULL "; } $valor = " "; if ($columna->auto != NULL) { if ($columna->tipoDato->tipo == "BIT" || $columna->tipoDato->tipo == "TINYINT" || $columna->tipoDato->tipo == "SMALLINT" || $columna->tipoDato->tipo == "MEDIUMINT" || $columna->tipoDato->tipo == "INT" || $columna->tipoDato->tipo == "DOUBLE" || $columna->tipoDato->tipo == "FLOAT" || $columna->tipoDato->tipo == "NUMERIC") { $valor .= $columna->auto; } else { $valor = "'" . $columna->auto . "'"; } $cadena .= " DEFAULT " . $valor; } if ($columna->isAutoIncrement) { $cadena .= " AUTO_INCREMENT "; } if ($columna->isUnique) { $cadena .= " UNIQUE "; } if ($columna->isPrimary) { $cadena .= " PRIMARY KEy "; } return $cadena; }
function sqlColumnaAlter($columna, $viejoNombre = NULL) { $cadena = " "; if ($viejoNombre != NULL) { $cadena .= $viejoNombre . " "; } $cadena .= $columna->name; $cadena .= sqlDato($columna->tipoDato); if (!$columna->isNull) { $cadena .= " NOT NULL "; } $valor = " "; if ($columna->auto != NULL) { if ($columna->tipoDato->tipo == "BIT" || $columna->tipoDato->tipo == "TINYINT" || $columna->tipoDato->tipo == "SMALLINT" || $columna->tipoDato->tipo == "MEDIUMINT" || $columna->tipoDato->tipo == "INT" || $columna->tipoDato->tipo == "DOUBLE" || $columna->tipoDato->tipo == "FLOAT" || $columna->tipoDato->tipo == "NUMERIC") { $valor .= $columna->auto; } else { $valor = "'" . $columna->auto . "'"; } $cadena .= " DEFAULT " . $valor; } return $cadena; }