non-quoted list of columns in relation view for internal relations
This commit is contained in:
@@ -1106,9 +1106,10 @@ class PMA_Table
|
|||||||
* - UNIQUE(x,y) // NONE
|
* - UNIQUE(x,y) // NONE
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
* @param boolean wether to quote name with backticks ``
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getUniqueColumns()
|
public function getUniqueColumns($quoted = true)
|
||||||
{
|
{
|
||||||
$sql = 'SHOW INDEX FROM ' . $this->getFullName(true) . ' WHERE Non_unique = 0';
|
$sql = 'SHOW INDEX FROM ' . $this->getFullName(true) . ' WHERE Non_unique = 0';
|
||||||
$uniques = PMA_DBI_fetch_result($sql, array('Key_name', null), 'Column_name');
|
$uniques = PMA_DBI_fetch_result($sql, array('Key_name', null), 'Column_name');
|
||||||
@@ -1118,7 +1119,7 @@ class PMA_Table
|
|||||||
if (count($index) > 1) {
|
if (count($index) > 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$return[] = $this->getFullName(true) . '.' . PMA_backquote($index[0]);
|
$return[] = $this->getFullName($quoted) . '.' . ($quoted ? PMA_backquote($index[0]) : $index[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
@@ -1134,7 +1135,7 @@ class PMA_Table
|
|||||||
* @param boolean wether to quote name with backticks ``
|
* @param boolean wether to quote name with backticks ``
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getIndexedColumns($quoted = false)
|
public function getIndexedColumns($quoted = true)
|
||||||
{
|
{
|
||||||
$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');
|
||||||
|
@@ -99,7 +99,7 @@ if (isset($destination) && $cfgRelation['relwork']) {
|
|||||||
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[$master_field])) {
|
if (! isset($existrel[$master_field])) {
|
||||||
$upd_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
|
$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)'
|
. '(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)) {
|
while ($curr_table = PMA_DBI_fetch_row($tab_rs)) {
|
||||||
$current_table = new PMA_Table($curr_table[0], $db);
|
$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
|
// if foreign keys are supported, collect all keys from other
|
||||||
// tables of the same engine
|
// tables of the same engine
|
||||||
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) {
|
||||||
// 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));
|
$selectboxall_foreign = array_merge($selectboxall_foreign, $current_table->getIndexedColumns(false));
|
||||||
}
|
}
|
||||||
} // end while over tables
|
} // end while over tables
|
||||||
|
Reference in New Issue
Block a user