mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-17 07:28:56 +00:00
[ticket/17524] Add index data getter to db tools
PHPBB-17524
This commit is contained in:
parent
aef616381e
commit
418aa469d7
1 changed files with 38 additions and 2 deletions
|
@ -435,6 +435,42 @@ class doctrine implements tools_interface
|
||||||
return $prefix && str_starts_with($name, $prefix) ? substr($name, strlen($prefix)) : $name;
|
return $prefix && str_starts_with($name, $prefix) ? substr($name, strlen($prefix)) : $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of the table index names and relevant data in format
|
||||||
|
* [
|
||||||
|
* [$index_name] = [
|
||||||
|
* 'columns' => (array) $index_columns,
|
||||||
|
* 'flags' => (array) $index_flags,
|
||||||
|
* 'options' => (array) $index_options,
|
||||||
|
* 'is_primary'=> (bool) $isPrimary,
|
||||||
|
* 'is_unique' => (bool) $isUnique,
|
||||||
|
* 'is_simple' => (bool) $isSimple,
|
||||||
|
* ]
|
||||||
|
*
|
||||||
|
* @param string $table_name
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function sql_get_table_index_data(string $table_name): array
|
||||||
|
{
|
||||||
|
$schema = $this->get_schema();
|
||||||
|
$table = $schema->getTable($table_name);
|
||||||
|
$indexes = [];
|
||||||
|
foreach ($table->getIndexes() as $index)
|
||||||
|
{
|
||||||
|
$indexes[$index->getName()] = [
|
||||||
|
'columns' => array_map('strtolower', $index->getUnquotedColumns()),
|
||||||
|
'flags' => $index->getFlags(),
|
||||||
|
'options' => $index->getOptions(),
|
||||||
|
'is_primary'=> $index->isPrimary(),
|
||||||
|
'is_unique' => $index->isUnique(),
|
||||||
|
'is_simple' => $index->isSimpleIndex(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $indexes;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of indices for either unique and primary keys, or simple indices.
|
* Returns an array of indices for either unique and primary keys, or simple indices.
|
||||||
*
|
*
|
||||||
|
@ -1023,8 +1059,8 @@ class doctrine implements tools_interface
|
||||||
return $parts[1];
|
return $parts[1];
|
||||||
}
|
}
|
||||||
return $column;
|
return $column;
|
||||||
}, $columns);
|
}, $columns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue