From c58cc5604127439d1d4465ebc720ffd01cba860c Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Mon, 26 Mar 2007 14:48:30 +0000 Subject: [PATCH] documentation --- pmd_common.php | 186 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 130 insertions(+), 56 deletions(-) diff --git a/pmd_common.php b/pmd_common.php index a1e30979f..75146c30e 100644 --- a/pmd_common.php +++ b/pmd_common.php @@ -18,54 +18,79 @@ $GLOBALS['PMD']['STYLE'] = 'default'; require_once './libraries/relation.lib.php'; $cfgRelation = PMA_getRelationsParam(); -$script_display_field = "\n"; + $GLOBALS['script_display_field'] .= "\n"; // return $GLOBALS['PMD']; // many bases // not use ?????? } -function get_tab_info() // PMA_DBI //PMA_backquote +/** + * retrieves table column info + * + * @uses $GLOBALS['db'] + * @uses PMA_DBI_QUERY_STORE + * @uses PMA_DBI_select_db() + * @uses PMA_DBI_query() + * @uses PMA_DBI_num_rows() + * @uses PMA_backquote() + * @uses count() + * @return array table column nfo + */ +function get_tab_info() { - global $db; - PMA_DBI_select_db($db); + PMA_DBI_select_db($GLOBALS['db']); $tab_column = array(); - for ( $i=0; $i < sizeof( $GLOBALS['PMD']["TABLE_NAME"] ); $i++ ) { - PMA_DBI_select_db($db); + for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) { $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM '.PMA_backquote($GLOBALS['PMD']["TABLE_NAME_SMALL"][$i]), NULL, PMA_DBI_QUERY_STORE); - $fields_cnt = PMA_DBI_num_rows($fields_rs); - $j=0; + $j = 0; while ($row = PMA_DBI_fetch_assoc($fields_rs)) { $tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['COLUMN_ID'][$j] = $j; $tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['COLUMN_NAME'][$j] = $row['Field']; @@ -74,36 +99,51 @@ function get_tab_info() // PMA_DBI //PMA_backquote $j++; } } -return $tab_column; + return $tab_column; } -//-------------------------------------CONTR----------------------------------------------- -function get_script_contr() { - global $db; - PMA_DBI_select_db($db); + +/** + * returns JavaScript code for intializing vars + * + * @uses $GLOBALS['db'] + * @uses PMA_DBI_QUERY_STORE + * @uses PMA_DBI_select_db() + * @uses PMA_DBI_query() + * @uses PMA_backquote() + * @uses PMA_DBI_fetch_row() + * @uses PMA_getForeigners() + * @uses urlencode() + * @uses count() + * @uses in_array() + * @return string JavaScript code + */ +function get_script_contr() +{ + PMA_DBI_select_db($GLOBALS['db']); $con["C_NAME"] = array(); $i = 0; - $alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db), NULL, PMA_DBI_QUERY_STORE); + $alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($GLOBALS['db']), NULL, PMA_DBI_QUERY_STORE); while ($val = @PMA_DBI_fetch_row($alltab_rs)) { - $row = PMA_getForeigners($db,$val[0],'','internal'); - //echo "
internal ".$db." - ".$val[0]." - "; + $row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'internal'); + //echo "
internal ".$GLOBALS['db']." - ".$val[0]." - "; //print_r($row ); if ($row !== false) { foreach ($row as $field => $value) { $con['C_NAME'][$i] = ''; - $con['DTN'][$i] = urlencode($db . "." . $val[0]); + $con['DTN'][$i] = urlencode($GLOBALS['db'] . "." . $val[0]); $con['DCN'][$i] = urlencode($field); $con['STN'][$i] = urlencode($value['foreign_db'] . "." . $value['foreign_table']); $con['SCN'][$i] = urlencode($value['foreign_field']); $i++; } } - $row = PMA_getForeigners($db,$val[0],'','innodb'); + $row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'innodb'); //echo "
INNO "; //print_r($row ); if ($row !== false) { foreach ($row as $field => $value) { $con['C_NAME'][$i] = ''; - $con['DTN'][$i] = urlencode($db.".".$val[0]); + $con['DTN'][$i] = urlencode($GLOBALS['db'].".".$val[0]); $con['DCN'][$i] = urlencode($field); $con['STN'][$i] = urlencode($value['foreign_db'].".".$value['foreign_table']); $con['SCN'][$i] = urlencode($value['foreign_field']); @@ -114,29 +154,44 @@ function get_script_contr() { $ti = 0; $script_contr = "\n"; return $script_contr; } -function get_pk_or_unique_keys() { - global $db; - require_once('./libraries/tbl_indexes.lib.php'); +/** + * @uses $GLOBALS['db'] + * @uses $GLOBALS['PMD'] + * @uses PMA_DBI_select_db() + * @uses PMA_get_indexes() + * @uses PMA_extract_indexes() + * @uses count() + * @return array unique or primary indizes + */ +function get_pk_or_unique_keys() +{ + require_once './libraries/tbl_indexes.lib.php'; - PMA_DBI_select_db($db); + PMA_DBI_select_db($GLOBALS['db']); $tables_pk_or_unique_keys = array(); - for( $I=0; $I $one_index) { $column_name = $one_index[1]['Column_name']; - if (isset($indexes_info[$key_name]) && $indexes_info[$key_name]['Non_unique'] == 0) { + if (isset($indexes_info[$key_name]) + && $indexes_info[$key_name]['Non_unique'] == 0) { $tables_pk_or_unique_keys[$GLOBALS['PMD']['OWNER'][$I] . '.' .$GLOBALS['PMD']['TABLE_NAME_SMALL'][$I] . '.' . $column_name] = 1; } } @@ -154,14 +210,25 @@ function get_pk_or_unique_keys() { return $tables_pk_or_unique_keys; } -function get_all_keys() { - global $db; - require_once('./libraries/tbl_indexes.lib.php'); +/** + * returns all indizes + * + * @uses $GLOBALS['db'] + * @uses $GLOBALS['PMD'] + * @uses PMA_DBI_select_db() + * @uses PMA_get_indexes() + * @uses PMA_extract_indexes() + * @uses count() + * @return array indizes + */ +function get_all_keys() +{ + require_once './libraries/tbl_indexes.lib.php'; - PMA_DBI_select_db($db); + PMA_DBI_select_db($GLOBALS['db']); $tables_all_keys = array(); - for( $I=0; $I