From 19a5d15d30bebaf3e39602babc33c149078d9cbf Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Thu, 23 Nov 2006 17:25:57 +0000 Subject: [PATCH] remove unneeded calls, and very if internal relations are enabled before trying to create one --- ChangeLog | 3 +++ pmd_common.php | 4 ++-- pmd_pdf.php | 1 - pmd_relation_new.php | 21 ++++++++++++--------- pmd_relation_upd.php | 2 -- pmd_save_pos.php | 1 - 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index a23ee23c1..65a68444c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,9 @@ $HeadURL$ 2006-11-23 Marc Delisle * pmd/scripts/move.js: fix a few js errors + * pmd*.php: remove unneeded calls to getRelationsParam(); + verify if the internal relations are enabled before trying to + create one 2006-11-22 Marc Delisle * Designer: get rid of pmd_config.php and pmd_get_info.php, diff --git a/pmd_common.php b/pmd_common.php index 7a5be9eeb..33249f4ae 100644 --- a/pmd_common.php +++ b/pmd_common.php @@ -10,6 +10,8 @@ require_once './libraries/common.lib.php'; $GLOBALS['PMD']['STYLE'] = 'default'; require_once './libraries/relation.lib.php'; +$cfgRelation = PMA_getRelationsParam(); + function get_tabs() // PMA_DBI { global $db; @@ -56,7 +58,6 @@ function get_script_contr() { global $db; PMA_DBI_select_db($db); $con["C_NAME"] = array(); - PMA_getRelationsParam(); $i = 0; $alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db), NULL, PMA_DBI_QUERY_STORE); while ($val = @PMA_DBI_fetch_row($alltab_rs)) { @@ -159,7 +160,6 @@ function get_script_tabs() { } function get_tab_pos() { - PMA_getRelationsParam(); $stmt = PMA_query_as_cu("SELECT * FROM " . PMA_backquote($GLOBALS['cfgRelation']['designer_coords']), FALSE, PMA_DBI_QUERY_STORE); if ( $stmt ) // exist table repository { diff --git a/pmd_pdf.php b/pmd_pdf.php index 1444277aa..0c27015c6 100644 --- a/pmd_pdf.php +++ b/pmd_pdf.php @@ -13,7 +13,6 @@ if (isset($scale)) { if (empty($pdf_page_number)) { die(""); } - $cfgRelation = PMA_getRelationsParam(); $pmd_table = PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['designer_coords']); $pma_table = PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']); diff --git a/pmd_relation_new.php b/pmd_relation_new.php index 45559f918..5cad818ee 100644 --- a/pmd_relation_new.php +++ b/pmd_relation_new.php @@ -7,7 +7,6 @@ $die_save_pos = 0; include_once 'pmd_save_pos.php'; require_once './libraries/relation.lib.php'; extract($_POST); -PMA_getRelationsParam(); $tables = PMA_DBI_get_tables_full($db, $T1); $type_T1 = strtoupper($tables[$T1]['ENGINE']); @@ -58,16 +57,20 @@ if ($type_T1 == 'INNODB' and $type_T2 == 'INNODB') { // n o n - I n n o D B } else { - // no need to recheck if the keys are primary or unique at this point, - // this was checked on the interface part + if ($GLOBALS['cfgRelation']['relwork'] == false) { + PMD_return(0, $strGeneralRelationFeat . ' : ' . $strDisabled); + } else { + // no need to recheck if the keys are primary or unique at this point, + // this was checked on the interface part - $q = "INSERT INTO ".PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])." - (master_db, master_table, master_field, foreign_db, foreign_table, foreign_field) - VALUES ('".$db."','".$T2."','$F2','". - $db."','".$T1."','$F1')"; - PMA_query_as_cu( $q , true, PMA_DBI_QUERY_STORE);// or PMD_return(0,'ERROR : Relation not added!'); + $q = "INSERT INTO ".PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])." + (master_db, master_table, master_field, foreign_db, foreign_table, foreign_field) + VALUES ('".$db."','".$T2."','$F2','". + $db."','".$T1."','$F1')"; + PMA_query_as_cu( $q , true, PMA_DBI_QUERY_STORE);// or PMD_return(0,'ERROR : Relation not added!'); - PMD_return(1, $strInternalRelationAdded); + PMD_return(1, $strInternalRelationAdded); + } } function PMD_return($b,$ret) diff --git a/pmd_relation_upd.php b/pmd_relation_upd.php index 1f01ebf17..daf370612 100644 --- a/pmd_relation_upd.php +++ b/pmd_relation_upd.php @@ -11,8 +11,6 @@ include_once 'pmd_save_pos.php'; list($DB1,$T1) = explode(".",$T1); list($DB2,$T2) = explode(".",$T2); -PMA_getRelationsParam(); - //++++++++++++++++++++++++++++++++++++++++++++++++++++ InnoDB ++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/pmd_save_pos.php b/pmd_save_pos.php index f5df17f94..455954cf0 100644 --- a/pmd_save_pos.php +++ b/pmd_save_pos.php @@ -4,7 +4,6 @@ include_once 'pmd_common.php'; require_once './libraries/relation.lib.php'; -PMA_getRelationsParam(); $alltab_rs = PMA_query_as_cu('SHOW TABLES FROM '.PMA_backquote($cfg['Server']['pmadb']),FALSE,PMA_DBI_QUERY_STORE) or PMD_err_sav();