From 21b89133e05e94885f63bb295b0ea3430549e3e1 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sun, 29 Jul 2012 18:52:16 +0530 Subject: [PATCH] Some coding style improvements --- libraries/DisplayResults.class.php | 5 ++++- pmd_pdf.php | 15 +++++++++++---- pmd_relation_new.php | 18 ++++++++---------- pmd_save_pos.php | 9 ++++++--- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 1966ff6064..f5a0af3383 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -1431,7 +1431,10 @@ class PMA_DisplayResults && ($direction != self::DISP_DIR_HORIZONTAL_FLIPPED) ) { $comments_map = array(); - if (isset($analyzed_sql[0]) && is_array($analyzed_sql[0]) && isset($analyzed_sql[0]['table_ref'])) { + if (isset($analyzed_sql[0]) + && is_array($analyzed_sql[0]) + && isset($analyzed_sql[0]['table_ref']) + ) { foreach ($analyzed_sql[0]['table_ref'] as $tbl) { $tb = $tbl['table_true_name']; $comments_map[$tb] = PMA_getComments($this->__get('_db'), $tb); diff --git a/pmd_pdf.php b/pmd_pdf.php index d5a1055261..69260da7cd 100644 --- a/pmd_pdf.php +++ b/pmd_pdf.php @@ -40,8 +40,10 @@ if (isset($mode)) { die(""); } - $pmd_table = $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($GLOBALS['cfgRelation']['designer_coords']); - $pma_table = $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($cfgRelation['table_coords']); + $pmd_table = $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $common_functions->backquote($GLOBALS['cfgRelation']['designer_coords']); + $pma_table = $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $common_functions->backquote($cfgRelation['table_coords']); $scale_q = $common_functions->sqlAddSlashes($scale); if ('create_export' == $mode) { @@ -57,7 +59,12 @@ if (isset($mode)) { $pdf_page_number_q = $common_functions->sqlAddSlashes($pdf_page_number); if ('export' == $mode) { - $sql = "REPLACE INTO " . $pma_table . " (db_name, table_name, pdf_page_number, x, y) SELECT db_name, table_name, " . $pdf_page_number_q . ", ROUND(x/" . $scale_q . ") , ROUND(y/" . $scale_q . ") y FROM " . $pmd_table . " WHERE db_name = '" . $common_functions->sqlAddSlashes($db) . "'"; + $sql = "REPLACE INTO " . $pma_table + . " (db_name, table_name, pdf_page_number, x, y)" + . " SELECT db_name, table_name, " . $pdf_page_number_q . "," + . " ROUND(x/" . $scale_q . ") , ROUND(y/" . $scale_q . ") y" + . " FROM " . $pmd_table + . " WHERE db_name = '" . $common_functions->sqlAddSlashes($db) . "'"; PMA_queryAsControlUser($sql, true, PMA_DBI_QUERY_STORE); } @@ -72,7 +79,7 @@ if (isset($mode)) { AND ' . $pmd_table . '.`table_name` = ' . $pma_table . '.`table_name` AND - ' . $pmd_table . '.`db_name`=\''. $common_functions->sqlAddSlashes($db) .'\' + ' . $pmd_table . '.`db_name`=\''. $common_functions->sqlAddSlashes($db) . '\' AND pdf_page_number = ' . $pdf_page_number_q . ';', true, PMA_DBI_QUERY_STORE ); diff --git a/pmd_relation_new.php b/pmd_relation_new.php index bb8cb8b1cd..d78a8eb77e 100644 --- a/pmd_relation_new.php +++ b/pmd_relation_new.php @@ -35,14 +35,14 @@ if ($common_functions->isForeignKeySupported($type_T1) ) { PMD_return_new(0, __('Error: relation already exists.')); } -// note: in InnoDB, the index does not requires to be on a PRIMARY -// or UNIQUE key -// improve: check all other requirements for InnoDB relations + // note: in InnoDB, the index does not requires to be on a PRIMARY + // or UNIQUE key + // improve: check all other requirements for InnoDB relations $result = PMA_DBI_query( 'SHOW INDEX FROM ' . $common_functions->backquote($db) . '.' . $common_functions->backquote($T1) . ';' ); - $index_array1 = array(); // will be use to emphasis prim. keys in the table view + $index_array1 = array(); // will be use to emphasis prim. keys in the table view while ($row = PMA_DBI_fetch_assoc($result)) { $index_array1[$row['Column_name']] = 1; } @@ -52,7 +52,7 @@ if ($common_functions->isForeignKeySupported($type_T1) 'SHOW INDEX FROM ' . $common_functions->backquote($db) . '.' . $common_functions->backquote($T2) . ';' ); - $index_array2 = array(); // will be used to emphasis prim. keys in the table view + $index_array2 = array(); // will be used to emphasis prim. keys in the table view while ($row = PMA_DBI_fetch_assoc($result)) { $index_array2[$row['Column_name']] = 1; } @@ -76,11 +76,9 @@ if ($common_functions->isForeignKeySupported($type_T1) } $upd_query .= ';'; PMA_DBI_try_query($upd_query) or PMD_return_new(0, __('Error: Relation not added.')); - PMD_return_new(1, __('FOREIGN KEY relation added')); + PMD_return_new(1, __('FOREIGN KEY relation added')); } - -// internal (pmadb) relation -} else { +} else { // internal (pmadb) relation if ($GLOBALS['cfgRelation']['relwork'] == false) { PMD_return_new(0, _('General relation features') . ':' . _('Disabled')); } else { @@ -102,7 +100,7 @@ if ($common_functions->isForeignKeySupported($type_T1) } else { PMD_return_new(0, __('Error: Relation not added.')); } - } + } } function PMD_return_new($b,$ret) diff --git a/pmd_save_pos.php b/pmd_save_pos.php index a0cfc944ea..a009ef146a 100644 --- a/pmd_save_pos.php +++ b/pmd_save_pos.php @@ -38,17 +38,20 @@ foreach ($post_params as $one_post_param) { } foreach ($t_x as $key => $value) { - $KEY = empty($IS_AJAX) ? urldecode($key) : $key; // table name decode (post PDF exp/imp) + // table name decode (post PDF exp/imp) + $KEY = empty($IS_AJAX) ? urldecode($key) : $key; list($DB,$TAB) = explode(".", $KEY); PMA_queryAsControlUser( - 'DELETE FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($GLOBALS['cfgRelation']['designer_coords']) + 'DELETE FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) + . '.' . $common_functions->backquote($GLOBALS['cfgRelation']['designer_coords']) . ' WHERE `db_name` = \'' . $common_functions->sqlAddSlashes($DB) . '\'' . ' AND `table_name` = \'' . $common_functions->sqlAddSlashes($TAB) . '\'', true, PMA_DBI_QUERY_STORE ); PMA_queryAsControlUser( - 'INSERT INTO ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($GLOBALS['cfgRelation']['designer_coords']) + 'INSERT INTO ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) + . '.' . $common_functions->backquote($GLOBALS['cfgRelation']['designer_coords']) . ' (db_name, table_name, x, y, v, h)' . ' VALUES (' . '\'' . $common_functions->sqlAddSlashes($DB) . '\', '