relation view: foreign key changes for options ON DELETE/ON UPDATE on existing relations did not work in trunk
This commit is contained in:
@@ -1131,17 +1131,17 @@ class PMA_Table
|
|||||||
* first columns in an index
|
* first columns in an index
|
||||||
*
|
*
|
||||||
* f.e. index(col1, col2) would only return col1
|
* f.e. index(col1, col2) would only return col1
|
||||||
*
|
* @param boolean wether to quote name with backticks ``
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getIndexedColumns()
|
public function getIndexedColumns($quoted = false)
|
||||||
{
|
{
|
||||||
$sql = 'SHOW INDEX FROM ' . $this->getFullName(true) . ' WHERE Seq_in_index = 1';
|
$sql = 'SHOW INDEX FROM ' . $this->getFullName(true) . ' WHERE Seq_in_index = 1';
|
||||||
$indexed = PMA_DBI_fetch_result($sql, 'Column_name', 'Column_name');
|
$indexed = PMA_DBI_fetch_result($sql, 'Column_name', 'Column_name');
|
||||||
|
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach ($indexed as $column) {
|
foreach ($indexed as $column) {
|
||||||
$return[] = $this->getFullName(true) . '.' . PMA_backquote($column);
|
$return[] = $this->getFullName($quoted) . '.' . ($quoted ? PMA_backquote($column) : $column);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
@@ -144,7 +144,7 @@ if (isset($_REQUEST['destination_foreign'])) {
|
|||||||
if (! empty($foreign_string)) {
|
if (! empty($foreign_string)) {
|
||||||
$foreign_string = trim($foreign_string, '`');
|
$foreign_string = trim($foreign_string, '`');
|
||||||
list($foreign_db, $foreign_table, $foreign_field) =
|
list($foreign_db, $foreign_table, $foreign_field) =
|
||||||
explode('`.`', $foreign_string);
|
explode('.', $foreign_string);
|
||||||
if (!isset($existrel_foreign[$master_field])) {
|
if (!isset($existrel_foreign[$master_field])) {
|
||||||
// no key defined for this field
|
// no key defined for this field
|
||||||
|
|
||||||
@@ -198,11 +198,11 @@ if (isset($_REQUEST['destination_foreign'])) {
|
|||||||
. PMA_backquote($foreign_table) . '('
|
. PMA_backquote($foreign_table) . '('
|
||||||
. PMA_backquote($foreign_field) . ')';
|
. PMA_backquote($foreign_field) . ')';
|
||||||
|
|
||||||
if ($_REQUEST['on_delete'][$master_field] != 'nix') {
|
if (! empty($_REQUEST['on_delete'][$master_field])) {
|
||||||
$sql_query .= ' ON DELETE '
|
$sql_query .= ' ON DELETE '
|
||||||
. $options_array[$_REQUEST['on_delete'][$master_field]];
|
. $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 '
|
$sql_query .= ' ON UPDATE '
|
||||||
. $options_array[$_REQUEST['on_update'][$master_field]];
|
. $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)
|
if (PMA_foreignkey_supported($tbl_type)
|
||||||
&& isset($curr_table[1])
|
&& isset($curr_table[1])
|
||||||
&& strtoupper($curr_table[1]) == $tbl_type) {
|
&& 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 while over tables
|
||||||
} // end if
|
} // end if
|
||||||
|
|
||||||
|
|
||||||
// Now find out the columns of our $table
|
// Now find out the columns of our $table
|
||||||
// need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli
|
// 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);
|
$col_rs = PMA_DBI_try_query('SHOW COLUMNS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
|
||||||
|
Reference in New Issue
Block a user