Pad the lengths of the columns
This commit is contained in:
parent
a827f948c8
commit
4095e6c9be
|
@ -167,6 +167,7 @@ class DBStructure
|
||||||
$tables = [];
|
$tables = [];
|
||||||
foreach (self::definition(null) as $name => $definition) {
|
foreach (self::definition(null) as $name => $definition) {
|
||||||
$fields = [];
|
$fields = [];
|
||||||
|
$lengths = [];
|
||||||
foreach ($definition['fields'] as $key => $value) {
|
foreach ($definition['fields'] as $key => $value) {
|
||||||
$field = [];
|
$field = [];
|
||||||
$field['name'] = $key;
|
$field['name'] = $key;
|
||||||
|
@ -177,8 +178,17 @@ class DBStructure
|
||||||
$field['default'] = $value['default'] ?? 'NULL';
|
$field['default'] = $value['default'] ?? 'NULL';
|
||||||
$field['extra'] = $value['extra'] ?? '';
|
$field['extra'] = $value['extra'] ?? '';
|
||||||
|
|
||||||
|
foreach ($field as $fieldname => $fieldvalue) {
|
||||||
|
$lengths[$fieldname] = max($lengths[$fieldname] ?? 0, strlen($fieldvalue));
|
||||||
|
}
|
||||||
$fields[] = $field;
|
$fields[] = $field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
array_walk_recursive($fields, function(&$value, $key) use ($lengths)
|
||||||
|
{
|
||||||
|
$value = str_pad($value, $lengths[$key]);
|
||||||
|
});
|
||||||
|
|
||||||
$tables[] = ['name' => $name, 'comment' => $definition['comment']];
|
$tables[] = ['name' => $name, 'comment' => $definition['comment']];
|
||||||
$content = Renderer::replaceMacros(Renderer::getMarkupTemplate('structure.tpl'), [
|
$content = Renderer::replaceMacros(Renderer::getMarkupTemplate('structure.tpl'), [
|
||||||
'$name' => $name,
|
'$name' => $name,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user