Get foreigners just once for table and use it for all columns
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
This commit is contained in:
parent
5a4d8a3855
commit
2abae135e6
@ -1665,20 +1665,28 @@ function PMA_getChildReferences($db, $table, $column)
|
||||
/**
|
||||
* Check child table references and foreign key for a table column.
|
||||
*
|
||||
* @param string $db name of master table db.
|
||||
* @param string $table name of master table.
|
||||
* @param string $column name of master table column.
|
||||
* @param string $db name of master table db.
|
||||
* @param string $table name of master table.
|
||||
* @param string $column name of master table column.
|
||||
* @param array $foreigners_full foreiners array for the whole table.
|
||||
*
|
||||
* @return array $column_status telling about references if foreign key.
|
||||
*/
|
||||
function PMA_checkChildForeignReferences($db, $table, $column)
|
||||
{
|
||||
function PMA_checkChildForeignReferences(
|
||||
$db, $table, $column, $foreigners_full = null
|
||||
) {
|
||||
$column_status = array();
|
||||
$column_status['isEditable'] = false;
|
||||
$column_status['isReferenced'] = false;
|
||||
$column_status['isForeignKey'] = false;
|
||||
$column_status['references'] = array();
|
||||
$foreigners = PMA_getForeigners($db, $table, $column);
|
||||
$foreigners = array();
|
||||
if ($foreigners_full) {
|
||||
$foreigners = $foreigners_full[$column];
|
||||
} else {
|
||||
$foreigners = PMA_getForeigners($db, $table, $column);
|
||||
}
|
||||
|
||||
$foreigner = PMA_searchColumnInForeigners($foreigners, $column);
|
||||
$child_references = PMA_getChildReferences($db, $table, $column);
|
||||
|
||||
|
||||
@ -91,6 +91,7 @@ if (isset($_REQUEST['submit_num_fields'])) {
|
||||
$regenerate = 1;
|
||||
}
|
||||
|
||||
$foreigners = PMA_getForeigners($db, $table);
|
||||
for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
|
||||
if (! empty($regenerate)) {
|
||||
list($columnMeta, $submit_length, $submit_attribute,
|
||||
@ -144,7 +145,8 @@ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
|
||||
$columnMeta['column_status'] = PMA_checkChildForeignReferences(
|
||||
$_form_params['db'],
|
||||
$_form_params['table'],
|
||||
$columnMeta['Field']
|
||||
$columnMeta['Field'],
|
||||
$foreigners
|
||||
);
|
||||
}
|
||||
// old column attributes
|
||||
|
||||
Loading…
Reference in New Issue
Block a user