From 2dc280458fa99ce9b071d6e857050054535acb7b Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Fri, 23 May 2008 12:19:20 +0000 Subject: [PATCH] non-quoted list of columns in relation view for internal relations --- libraries/Table.class.php | 7 ++++--- tbl_relation.php | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libraries/Table.class.php b/libraries/Table.class.php index a713c2260..c55bf4703 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -1106,9 +1106,10 @@ class PMA_Table * - UNIQUE(x,y) // NONE * * + * @param boolean wether to quote name with backticks `` * @return array */ - public function getUniqueColumns() + public function getUniqueColumns($quoted = true) { $sql = 'SHOW INDEX FROM ' . $this->getFullName(true) . ' WHERE Non_unique = 0'; $uniques = PMA_DBI_fetch_result($sql, array('Key_name', null), 'Column_name'); @@ -1118,7 +1119,7 @@ class PMA_Table if (count($index) > 1) { continue; } - $return[] = $this->getFullName(true) . '.' . PMA_backquote($index[0]); + $return[] = $this->getFullName($quoted) . '.' . ($quoted ? PMA_backquote($index[0]) : $index[0]); } return $return; @@ -1134,7 +1135,7 @@ class PMA_Table * @param boolean wether to quote name with backticks `` * @return array */ - public function getIndexedColumns($quoted = false) + public function getIndexedColumns($quoted = true) { $sql = 'SHOW INDEX FROM ' . $this->getFullName(true) . ' WHERE Seq_in_index = 1'; $indexed = PMA_DBI_fetch_result($sql, 'Column_name', 'Column_name'); diff --git a/tbl_relation.php b/tbl_relation.php index 1f2b81704..18256d96a 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -99,7 +99,7 @@ if (isset($destination) && $cfgRelation['relwork']) { if (! empty($foreign_string)) { $foreign_string = trim($foreign_string, '`'); list($foreign_db, $foreign_table, $foreign_field) = - explode('`.`', $foreign_string); + explode('.', $foreign_string); if (! isset($existrel[$master_field])) { $upd_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) . '(master_db, master_table, master_field, foreign_db, foreign_table, foreign_field)' @@ -324,14 +324,15 @@ if ($cfgRelation['relwork'] || PMA_foreignkey_supported($tbl_type)) { while ($curr_table = PMA_DBI_fetch_row($tab_rs)) { $current_table = new PMA_Table($curr_table[0], $db); - $selectboxall = array_merge($selectboxall, $current_table->getUniqueColumns()); + // explicitely ask for non-quoted list of indexed columns + $selectboxall = array_merge($selectboxall, $current_table->getUniqueColumns(false)); // if foreign keys are supported, collect all keys from other // tables of the same engine if (PMA_foreignkey_supported($tbl_type) && isset($curr_table[1]) && strtoupper($curr_table[1]) == $tbl_type) { - // explicitely ask for non-quoted list of columns + // explicitely ask for non-quoted list of indexed columns $selectboxall_foreign = array_merge($selectboxall_foreign, $current_table->getIndexedColumns(false)); } } // end while over tables