From a727fb367d003a9ddabbedd96e4c5dfc2b1b4fec Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 11 May 2008 12:38:26 +0000 Subject: [PATCH] relation view: foreign key changes for options ON DELETE/ON UPDATE on existing relations did not work in trunk --- libraries/Table.class.php | 6 +++--- tbl_relation.php | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libraries/Table.class.php b/libraries/Table.class.php index 57bcd9a05..a713c2260 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -1131,17 +1131,17 @@ class PMA_Table * first columns in an index * * f.e. index(col1, col2) would only return col1 - * + * @param boolean wether to quote name with backticks `` * @return array */ - public function getIndexedColumns() + public function getIndexedColumns($quoted = false) { $sql = 'SHOW INDEX FROM ' . $this->getFullName(true) . ' WHERE Seq_in_index = 1'; $indexed = PMA_DBI_fetch_result($sql, 'Column_name', 'Column_name'); $return = array(); foreach ($indexed as $column) { - $return[] = $this->getFullName(true) . '.' . PMA_backquote($column); + $return[] = $this->getFullName($quoted) . '.' . ($quoted ? PMA_backquote($column) : $column); } return $return; diff --git a/tbl_relation.php b/tbl_relation.php index d0b66e1ab..1f2b81704 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -144,7 +144,7 @@ if (isset($_REQUEST['destination_foreign'])) { 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_foreign[$master_field])) { // no key defined for this field @@ -198,11 +198,11 @@ if (isset($_REQUEST['destination_foreign'])) { . PMA_backquote($foreign_table) . '(' . PMA_backquote($foreign_field) . ')'; - if ($_REQUEST['on_delete'][$master_field] != 'nix') { + if (! empty($_REQUEST['on_delete'][$master_field])) { $sql_query .= ' ON DELETE ' . $options_array[$_REQUEST['on_delete'][$master_field]]; } - if ($_REQUEST['on_update'][$master_field] != 'nix') { + if (! empty($_REQUEST['on_update'][$master_field])) { $sql_query .= ' ON UPDATE ' . $options_array[$_REQUEST['on_update'][$master_field]]; } @@ -331,12 +331,12 @@ if ($cfgRelation['relwork'] || PMA_foreignkey_supported($tbl_type)) { if (PMA_foreignkey_supported($tbl_type) && isset($curr_table[1]) && strtoupper($curr_table[1]) == $tbl_type) { - $selectboxall_foreign = array_merge($selectboxall_foreign, $current_table->getIndexedColumns()); + // explicitely ask for non-quoted list of columns + $selectboxall_foreign = array_merge($selectboxall_foreign, $current_table->getIndexedColumns(false)); } } // end while over tables } // end if - // Now find out the columns of our $table // need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli $col_rs = PMA_DBI_try_query('SHOW COLUMNS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);