' . "\n" .
'// ' . "\n" .
'' . "\n";
// return $GLOBALS['PMD']; // many bases // not use ??????
}
/**
* 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()
{
PMA_DBI_select_db($GLOBALS['db']);
$tab_column = array();
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);
$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'];
$tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['TYPE'][$j] = $row['Type'];
$tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['NULLABLE'][$j] = $row['Null'];
$j++;
}
}
return $tab_column;
}
/**
* 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($GLOBALS['db']), NULL, PMA_DBI_QUERY_STORE);
while ($val = @PMA_DBI_fetch_row($alltab_rs)) {
$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($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($GLOBALS['db'], $val[0], '', 'foreign');
//echo "
INNO ";
//print_r($row);
if ($row !== false) {
foreach ($row as $field => $value) {
$con['C_NAME'][$i] = '';
$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++;
}
}
}
$ti = 0;
$script_contr =
'' . "\n";
return $script_contr;
}
/**
* @uses get_all_keys()
* @return array unique or primary indizes
*/
function get_pk_or_unique_keys()
{
return get_all_keys(true);
}
/**
* returns all indizes
*
* @uses $GLOBALS['PMD']
* @uses PMA_Index::getFromTable()
* @uses PMA_Index->isUnique()
* @uses PMA_Index->getColumns()
* @param boolean whether to include ony unique ones
* @return array indizes
*/
function get_all_keys($unique_only = false)
{
require_once './libraries/Index.class.php';
$keys = array();
foreach ($GLOBALS['PMD']['TABLE_NAME_SMALL'] as $I => $table) {
$schema = $GLOBALS['PMD']['OWNER'][$I];
// for now, take into account only the first index segment
foreach (PMA_Index::getFromTable($table, $schema) as $index) {
if ($unique_only && ! $index->isUnique()) {
continue;
}
$columns = $index->getColumns();
foreach ($columns as $column_name => $dummy) {
$keys[$schema . '.' .$table . '.' . $column_name] = 1;
}
}
}
return $keys;
}
/**
*
*
* @uses $GLOBALS['PMD']
* @uses count()
* @uses in_array()
* @return array ???
*/
function get_script_tabs()
{
$script_tabs =
'' . "\n";
return $script_tabs;
}
/**
* @uses $GLOBALS['controllink']
* @uses $cfgRelation['designerwork']
* @uses $cfgRelation['db']
* @uses $cfgRelation['designer_coords']
* @uses PMA_DBI_QUERY_STORE
* @uses PMA_getRelationsParam()
* @uses PMA_backquote()
* @uses PMA_DBI_fetch_result()
* @uses count()
* @return array table positions and sizes
*/
function get_tab_pos()
{
$cfgRelation = PMA_getRelationsParam();
if (! $cfgRelation['designerwork']) {
return null;
}
$query = "
SELECT CONCAT_WS('.', `db_name`, `table_name`) AS `name`,
`x` AS `X`,
`y` AS `Y`,
`v` AS `V`,
`h` AS `H`
FROM " . PMA_backquote($cfgRelation['db']) . "." . PMA_backquote($cfgRelation['designer_coords']);
$tab_pos = PMA_DBI_fetch_result($query, 'name', null, $GLOBALS['controllink'], PMA_DBI_QUERY_STORE);
return count($tab_pos) ? $tab_pos : null;
}
/**
* returns distinct values from $GLOBALS['PMD']['OWNER']
*
* @uses array_values()
* @uses array_unique()
* @uses $GLOBALS['PMD']['OWNER']
* @return array owner
*/
function get_owners()
{
return array_values(array_unique($GLOBALS['PMD']['OWNER']));
}
get_tabs();
?>