mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 05:50:42 +02:00
Merge pull request #2474 from PayBas/ticket/12561
[ticket/12561] Add "after" check to schema_generator for columns_add * PayBas/ticket/12561: [ticket/12561] Reworked tests by nickvergessen [ticket/12561] Added tests for "after last", "after missing" and "empty" [ticket/12561] Add check to see if "after" column actually exists [ticket/12561] Added test for "after" [ticket/12561] Add "after" check to schema_generator for columns_add
This commit is contained in:
@@ -109,7 +109,25 @@ class schema_generator
|
||||
{
|
||||
foreach ($add_columns as $column => $column_data)
|
||||
{
|
||||
$this->tables[$table]['COLUMNS'][$column] = $column_data;
|
||||
if (isset($column_data['after']))
|
||||
{
|
||||
$columns = $this->tables[$table]['COLUMNS'];
|
||||
$offset = array_search($column_data['after'], array_keys($columns));
|
||||
unset($column_data['after']);
|
||||
|
||||
if ($offset === false)
|
||||
{
|
||||
$this->tables[$table]['COLUMNS'][$column] = array_values($column_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->tables[$table]['COLUMNS'] = array_merge(array_slice($columns, 0, $offset + 1, true), array($column => array_values($column_data)), array_slice($columns, $offset));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->tables[$table]['COLUMNS'][$column] = $column_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user