diff --git a/db_datadict.php b/db_datadict.php index 0e19ba1622..555063e7d3 100644 --- a/db_datadict.php +++ b/db_datadict.php @@ -72,44 +72,10 @@ foreach ($tables as $table) { /** * Gets table keys and retains them */ - $GLOBALS['dbi']->selectDb($db); - $indexes = $GLOBALS['dbi']->getTableIndexes($db, $table); - $primary = ''; - $lastIndex = ''; - $indexes_info = array(); - $indexes_data = array(); - $pk_array = array(); // will be use to emphasis prim. keys in the table - // view - foreach ($indexes as $row) { - // Backups the list of primary keys - if ($row['Key_name'] == 'PRIMARY') { - $primary .= $row['Column_name'] . ', '; - $pk_array[$row['Column_name']] = 1; - } - // Retains keys informations - if ($row['Key_name'] != $lastIndex) { - $indexes[] = $row['Key_name']; - $lastIndex = $row['Key_name']; - } - $indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index']; - $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique']; - if (isset($row['Cardinality'])) { - $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality']; - } - // I don't know what does following column mean.... - // $indexes_info[$row['Key_name']]['Packed'] = $row['Packed']; - - $indexes_info[$row['Key_name']]['Comment'] = $row['Comment']; - - $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] - = $row['Column_name']; - if (isset($row['Sub_part'])) { - $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] - = $row['Sub_part']; - } - - } // end while + $indexes = $GLOBALS['dbi']->getTableIndexes($db, $table); + list($primary, $pk_array, $indexes_info, $indexes_data) + = PMA_Util::processIndexData($indexes); /** * Gets columns properties diff --git a/libraries/Util.class.php b/libraries/Util.class.php index d7bb35ea33..c0ebdeeb37 100644 --- a/libraries/Util.class.php +++ b/libraries/Util.class.php @@ -4455,6 +4455,56 @@ class PMA_Util } return ""; } + + /** + * Process the index data. + * + * @param array $indexes index data + * + * @return array processes index data + */ + public static function processIndexData($indexes) + { + $lastIndex = ''; + + $primary = ''; + $pk_array = array(); // will be use to emphasis prim. keys in the table + $indexes_info = array(); + $indexes_data = array(); + + // view + foreach ($indexes as $row) { + // Backups the list of primary keys + if ($row['Key_name'] == 'PRIMARY') { + $primary .= $row['Column_name'] . ', '; + $pk_array[$row['Column_name']] = 1; + } + // Retains keys informations + if ($row['Key_name'] != $lastIndex) { + $indexes[] = $row['Key_name']; + $lastIndex = $row['Key_name']; + } + $indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index']; + $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique']; + if (isset($row['Cardinality'])) { + $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality']; + } + // I don't know what does following column mean.... + // $indexes_info[$row['Key_name']]['Packed'] = $row['Packed']; + + $indexes_info[$row['Key_name']]['Comment'] = $row['Comment']; + + $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] + = $row['Column_name']; + if (isset($row['Sub_part'])) { + $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] + = $row['Sub_part']; + } + + } // end while + + return array($primary, $pk_array, $indexes_info, $indexes_data); + } } ?> diff --git a/libraries/plugins/schema/pdf/Pdf_Relation_Schema.class.php b/libraries/plugins/schema/pdf/Pdf_Relation_Schema.class.php index 8965e42e71..bad6b850c3 100644 --- a/libraries/plugins/schema/pdf/Pdf_Relation_Schema.class.php +++ b/libraries/plugins/schema/pdf/Pdf_Relation_Schema.class.php @@ -965,48 +965,9 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema /** * Gets table keys and retains them */ - $result = $GLOBALS['dbi']->query( - 'SHOW KEYS FROM ' . PMA_Util::backquote($table) . ';' - ); - $primary = ''; - $indexes = array(); - $lastIndex = ''; - $indexes_info = array(); - $indexes_data = array(); - $pk_array = array(); // will be use to emphasis prim. keys in the table - // view - while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { - // Backups the list of primary keys - if ($row['Key_name'] == 'PRIMARY') { - $primary .= $row['Column_name'] . ', '; - $pk_array[$row['Column_name']] = 1; - } - // Retains keys information - if ($row['Key_name'] != $lastIndex) { - $indexes[] = $row['Key_name']; - $lastIndex = $row['Key_name']; - } - $indexes_info[$row['Key_name']]['Sequences'][] - = $row['Seq_in_index']; - $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique']; - if (isset($row['Cardinality'])) { - $indexes_info[$row['Key_name']]['Cardinality'] - = $row['Cardinality']; - } - // I don't know what does following column mean.... - // $indexes_info[$row['Key_name']]['Packed'] = $row['Packed']; - $indexes_info[$row['Key_name']]['Comment'] = $row['Comment']; - - $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] - = $row['Column_name']; - if (isset($row['Sub_part'])) { - $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] - = $row['Sub_part']; - } - } // end while - if ($result) { - $GLOBALS['dbi']->freeResult($result); - } + $indexes = $GLOBALS['dbi']->getTableIndexes($db, $table); + list($primary, $pk_array, $indexes_info, $indexes_data) + = PMA_Util::processIndexData($indexes); /** * Gets fields properties