Coding standards
This commit is contained in:
@@ -5,6 +5,13 @@ phpMyAdmin - Changelog
|
|||||||
$Id$
|
$Id$
|
||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
|
2002-07-11 Lo<4C>c Chapeaux <lolo@phpheaven.net>
|
||||||
|
* pdf_schema.php3; tbl_printview.php3; tbl_properties_links.php3;
|
||||||
|
tbl_properties_operations.php3; tbl_relation.php3;
|
||||||
|
libraries/charset_conversion.lib.php3; libraries/display_tbl.lib.php3;
|
||||||
|
libraries/relation.lib.php3: coding standards.
|
||||||
|
* libraries/common.lib.php3: coding standards and a little display bug.
|
||||||
|
|
||||||
2002-07-11 Alexander M. Turek <rabus@users.sourceforge.net>
|
2002-07-11 Alexander M. Turek <rabus@users.sourceforge.net>
|
||||||
* libraries/common.lib.php3: PHP3 compatibility.
|
* libraries/common.lib.php3: PHP3 compatibility.
|
||||||
* read_dump.php3: Fixed bug #579968, thanks to Alvar Soome (finsoft).
|
* read_dump.php3: Fixed bug #579968, thanks to Alvar Soome (finsoft).
|
||||||
|
@@ -13,21 +13,21 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
|
|||||||
/**
|
/**
|
||||||
* Loads the recode or iconv extensions if any of it is not loaded yet
|
* Loads the recode or iconv extensions if any of it is not loaded yet
|
||||||
*/
|
*/
|
||||||
if ( isset($cfg['AllowAnywhereRecoding'])
|
if (isset($cfg['AllowAnywhereRecoding'])
|
||||||
&& $cfg['AllowAnywhereRecoding']
|
&& $cfg['AllowAnywhereRecoding']
|
||||||
&& $allow_recoding
|
&& $allow_recoding
|
||||||
&& ((PMA_PHP_INT_VERSION >= 40000 && !@ini_get('safe_mode') && @ini_get('enable_dl'))
|
&& ((PMA_PHP_INT_VERSION >= 40000 && !@ini_get('safe_mode') && @ini_get('enable_dl'))
|
||||||
|| (PMA_PHP_INT_VERSION > 30009 && !@get_cfg_var('safe_mode')))
|
|| (PMA_PHP_INT_VERSION > 30009 && !@get_cfg_var('safe_mode')))
|
||||||
&& @function_exists('dl')) {
|
&& @function_exists('dl')) {
|
||||||
if (!(@extension_loaded('recode')||@extension_loaded('iconv'))) {
|
if (!(@extension_loaded('recode') || @extension_loaded('iconv'))) {
|
||||||
if (PMA_IS_WINDOWS) {
|
if (PMA_IS_WINDOWS) {
|
||||||
$suffix = '.dll';
|
$suffix = '.dll';
|
||||||
} else {
|
} else {
|
||||||
$suffix = '.so';
|
$suffix = '.so';
|
||||||
}
|
}
|
||||||
@dl('recode'.$suffix);
|
@dl('recode' . $suffix);
|
||||||
if (!@extension_loaded('recode')) {
|
if (!@extension_loaded('recode')) {
|
||||||
@dl('iconv'.$suffix);
|
@dl('iconv' . $suffix);
|
||||||
if (!@extension_loaded('iconv')) {
|
if (!@extension_loaded('iconv')) {
|
||||||
echo $strCantLoadRecodeIconv;
|
echo $strCantLoadRecodeIconv;
|
||||||
exit();
|
exit();
|
||||||
@@ -35,7 +35,6 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // end load mysql extension
|
} // end load mysql extension
|
||||||
// if allowed recoding, we should try to load extensions for it...
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -522,7 +522,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
|||||||
// work anyway, but display a big warning on the main.php3
|
// work anyway, but display a big warning on the main.php3
|
||||||
// page.
|
// page.
|
||||||
if (empty($cfg['PmaAbsoluteUri'])) {
|
if (empty($cfg['PmaAbsoluteUri'])) {
|
||||||
$port_in_HTTP_HOST = strpos($HTTP_SERVER_VARS['HTTP_HOST'], ':') > 0;
|
$port_in_HTTP_HOST = (strpos($HTTP_SERVER_VARS['HTTP_HOST'], ':') > 0);
|
||||||
$cfg['PmaAbsoluteUri'] = (!empty($HTTP_SERVER_VARS['HTTPS']) ? 'https' : 'http') . '://'
|
$cfg['PmaAbsoluteUri'] = (!empty($HTTP_SERVER_VARS['HTTPS']) ? 'https' : 'http') . '://'
|
||||||
. $HTTP_SERVER_VARS['HTTP_HOST']
|
. $HTTP_SERVER_VARS['HTTP_HOST']
|
||||||
. ((!empty($HTTP_SERVER_VARS['SERVER_PORT']) && !$port_in_HTTP_HOST) ? ':' . $HTTP_SERVER_VARS['SERVER_PORT'] : '')
|
. ((!empty($HTTP_SERVER_VARS['SERVER_PORT']) && !$port_in_HTTP_HOST) ? ':' . $HTTP_SERVER_VARS['SERVER_PORT'] : '')
|
||||||
@@ -1400,8 +1400,14 @@ if (typeof(document.getElementById) != 'undefined'
|
|||||||
global $PHP_SELF;
|
global $PHP_SELF;
|
||||||
global $db_details_links_count_tabs;
|
global $db_details_links_count_tabs;
|
||||||
|
|
||||||
$bgcolor = (basename($PHP_SELF) == $link) ? 'silver' : '#DFDFDF';
|
if (basename($PHP_SELF) == $link
|
||||||
$db_details_links_count_tabs++;
|
&& ($text != $GLOBALS['strEmpty'] && $text != $GLOBALS['strDrop'])) {
|
||||||
|
$bgcolor = 'silver';
|
||||||
|
} else {
|
||||||
|
$bgcolor = '#DFDFDF';
|
||||||
|
}
|
||||||
|
|
||||||
|
$db_details_links_count_tabs++;
|
||||||
if (!empty($attr)) {
|
if (!empty($attr)) {
|
||||||
$attr = ' ' . $attr;
|
$attr = ' ' . $attr;
|
||||||
}
|
}
|
||||||
|
@@ -1411,7 +1411,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')){
|
|||||||
while ($rel = PMA_mysql_fetch_row($result)) {
|
while ($rel = PMA_mysql_fetch_row($result)) {
|
||||||
// check for display field?
|
// check for display field?
|
||||||
if ($cfgRelation['displaywork']) {
|
if ($cfgRelation['displaywork']) {
|
||||||
$display_field = getDisplayField($db, $rel[2]);
|
$display_field = PMA_getDisplayField($db, $rel[2]);
|
||||||
} // end if
|
} // end if
|
||||||
$map[$rel[0]] = array($rel[2], $rel[3], $display_field);
|
$map[$rel[0]] = array($rel[2], $rel[3], $display_field);
|
||||||
} // end while
|
} // end while
|
||||||
|
@@ -1,45 +1,56 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set of functions used with the relation and pdf feature
|
* Set of functions used with the relation and pdf feature
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if (!defined('PMA_RELATION_LIB_INCLUDED')){
|
if (!defined('PMA_RELATION_LIB_INCLUDED')){
|
||||||
define('PMA_RELATION_LIB_INCLUDED', 1);
|
define('PMA_RELATION_LIB_INCLUDED', 1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* do a query as controluser if possible, otherwise
|
* Executes a query as controluser if possible, otherwise as normal user
|
||||||
* as normal user
|
*
|
||||||
* @return integer resultid
|
* @param string the query to execute
|
||||||
* @global string URL of Page to show in case of error
|
* @param boolean whether to display SQL error messages or not
|
||||||
* @global string Name of db to come back to
|
*
|
||||||
* @global integer Ressourceid of DB connect as controluser
|
* @return integer the result id
|
||||||
* @global array Configurationinfo about relationstuff
|
*
|
||||||
|
* @global string the URL of the page to show in case of error
|
||||||
|
* @global string the name of db to come back to
|
||||||
|
* @global integer the ressource id of DB connect as controluser
|
||||||
|
* @global array configuration infos about the relations stuff
|
||||||
*
|
*
|
||||||
* @author Mike Beck<mikebeck@users.sourceforge.net>
|
|
||||||
* @access public
|
* @access public
|
||||||
|
*
|
||||||
|
* @author Mike Beck <mikebeck@users.sourceforge.net>
|
||||||
*/
|
*/
|
||||||
function PMA_query_as_cu($sql,$showerror=TRUE) {
|
function PMA_query_as_cu($sql, $show_error = TRUE) {
|
||||||
global $err_url_0, $db, $dbh, $cfgRelation;
|
global $err_url_0, $db, $dbh, $cfgRelation;
|
||||||
|
|
||||||
if (isset($dbh)) {
|
if (isset($dbh)) {
|
||||||
PMA_mysql_select_db($cfgRelation['db'],$dbh);
|
PMA_mysql_select_db($cfgRelation['db'], $dbh);
|
||||||
$result = @PMA_mysql_query($sql, $dbh);
|
$result = @PMA_mysql_query($sql, $dbh);
|
||||||
if(!$result && $showerror==TRUE){
|
if (!$result && $show_error == TRUE) {
|
||||||
PMA_mysqlDie(mysql_error($dbh), $sql, '', $err_url_0);
|
PMA_mysqlDie(mysql_error($dbh), $sql, '', $err_url_0);
|
||||||
}
|
}
|
||||||
PMA_mysql_select_db($db,$dbh);
|
PMA_mysql_select_db($db, $dbh);
|
||||||
} else {
|
} else {
|
||||||
PMA_mysql_select_db($cfgRelation['db']);
|
PMA_mysql_select_db($cfgRelation['db']);
|
||||||
$result = @PMA_mysql_query($sql);
|
$result = @PMA_mysql_query($sql);
|
||||||
if($result && $showerror==TRUE){
|
if ($result && $show_error == TRUE) {
|
||||||
PMA_mysqlDie('', $sql, '', $err_url_0);
|
PMA_mysqlDie('', $sql, '', $err_url_0);
|
||||||
}
|
}
|
||||||
PMA_mysql_select_db($db);
|
PMA_mysql_select_db($db);
|
||||||
}
|
} // end if... else...
|
||||||
if($result){
|
|
||||||
|
if ($result) {
|
||||||
return $result;
|
return $result;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
} // end of the "PMA_query_as_cu()" function
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,168 +60,191 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){
|
|||||||
*
|
*
|
||||||
* @return array the relation parameters for the current user
|
* @return array the relation parameters for the current user
|
||||||
*
|
*
|
||||||
* @global array the list of settings for the current server
|
* @global array the list of settings for servers
|
||||||
* @global integer the id of the current server
|
* @global integer the id of the current server
|
||||||
* @author Mike Beck <mikebeck@users.sourceforge.net>
|
* @global string the URL of the page to show in case of error
|
||||||
|
* @global string the name of the current db
|
||||||
|
* @global string the name of the current table
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
*
|
||||||
|
* @author Mike Beck <mikebeck@users.sourceforge.net>
|
||||||
*/
|
*/
|
||||||
function PMA_getRelationsParam()
|
function PMA_getRelationsParam()
|
||||||
{
|
{
|
||||||
global $server, $err_url_0, $db, $table,$cfg;
|
global $cfg, $server, $err_url_0, $db, $table;
|
||||||
$cfgRelation = '';
|
|
||||||
|
|
||||||
|
$cfgRelation = '';
|
||||||
$cfgRelation['relwork'] = FALSE;
|
$cfgRelation['relwork'] = FALSE;
|
||||||
$cfgRelation['displaywork'] = FALSE;
|
$cfgRelation['displaywork'] = FALSE;
|
||||||
$cfgRelation['pdfwork'] = FALSE;
|
$cfgRelation['pdfwork'] = FALSE;
|
||||||
$cfgRelation['commwork'] = FALSE;
|
$cfgRelation['commwork'] = FALSE;
|
||||||
|
|
||||||
// No server selected -> no bookmark table
|
// No server selected -> no bookmark table
|
||||||
if ($server == 0
|
if ($server == 0
|
||||||
|| !isset($GLOBALS['cfg']['Server']['pmadb'])
|
|| empty($cfg['Server'])
|
||||||
|| empty($GLOBALS['cfg']['Server']['pmadb'])) {
|
|| empty($cfg['Server']['pmadb'])) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if pmadb exists
|
$cfgRelation['user'] = $cfg['Server']['user'];
|
||||||
$tab_query = 'SHOW DATABASES like \'' . $GLOBALS['cfg']['Server']['pmadb'] . '\'';
|
$cfgRelation['db'] = $cfg['Server']['pmadb'];
|
||||||
$tab_rs = PMA_query_as_cu($tab_query);
|
|
||||||
|
|
||||||
while ($curr_db = @PMA_mysql_fetch_array($tab_rs)) {
|
// Now I just check if all tables that i need are present so I can for
|
||||||
if($curr_db[0] == $cfg['Server']['pmadb']) {
|
// example enable relations but not pdf...
|
||||||
$cfgRelation['db'] = $GLOBALS['cfg']['Server']['pmadb'];
|
// I was thinking of checking if they have all required columns but I
|
||||||
}
|
// fear it might be too slow
|
||||||
}
|
|
||||||
if(!isset($cfgRelation['db'])){
|
|
||||||
$GLOBALS['cfg']['Server']['pmadb'] = FALSE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$cfgRelation['user'] = $GLOBALS['cfg']['Server']['user'];
|
|
||||||
$cfgRelation['db'] = $GLOBALS['cfg']['Server']['pmadb'];
|
|
||||||
|
|
||||||
// now i just check if all tables that i need are present
|
|
||||||
// so i can for example enable relations but not pdf...
|
|
||||||
// i was thinking of checking if they have all required columns
|
|
||||||
// but i fear it might be too slow
|
|
||||||
// PMA_mysql_select_db($cfgRelation['db']);
|
// PMA_mysql_select_db($cfgRelation['db']);
|
||||||
|
|
||||||
$tab_query = 'SHOW TABLES FROM ' . PMA_backquote($cfgRelation['db']);
|
$tab_query = 'SHOW TABLES FROM ' . PMA_backquote($cfgRelation['db']);
|
||||||
$tab_rs = PMA_query_as_cu($tab_query);
|
$tab_rs = PMA_query_as_cu($tab_query, FALSE);
|
||||||
|
|
||||||
//while ($curr_table = @PMA_mysql_fetch_array($tab_rs)) {
|
|
||||||
while ($curr_table = @PMA_mysql_fetch_array($tab_rs)) {
|
while ($curr_table = @PMA_mysql_fetch_array($tab_rs)) {
|
||||||
if($curr_table[0] == $cfg['Server']['bookmarktable']) {
|
if ($curr_table[0] == $cfg['Server']['bookmarktable']) {
|
||||||
continue;
|
continue;
|
||||||
} else if ($curr_table[0] == $GLOBALS['cfg']['Server']['relation']) {
|
} else if ($curr_table[0] == $cfg['Server']['relation']) {
|
||||||
$cfgRelation['relation'] = $curr_table[0];
|
$cfgRelation['relation'] = $curr_table[0];
|
||||||
} else if ($curr_table[0] == $GLOBALS['cfg']['Server']['table_info']) {
|
} else if ($curr_table[0] == $cfg['Server']['table_info']) {
|
||||||
$cfgRelation['table_info'] = $curr_table[0];
|
$cfgRelation['table_info'] = $curr_table[0];
|
||||||
} else if ($curr_table[0] == $GLOBALS['cfg']['Server']['table_coords']) {
|
} else if ($curr_table[0] == $cfg['Server']['table_coords']) {
|
||||||
$cfgRelation['table_coords'] = $curr_table[0];
|
$cfgRelation['table_coords'] = $curr_table[0];
|
||||||
} else if ($curr_table[0] == $GLOBALS['cfg']['Server']['column_comments']) {
|
} else if ($curr_table[0] == $cfg['Server']['column_comments']) {
|
||||||
$cfgRelation['column_comments'] = $curr_table[0];
|
$cfgRelation['column_comments'] = $curr_table[0];
|
||||||
} else if ($curr_table[0] == $GLOBALS['cfg']['Server']['pdf_pages']) {
|
} else if ($curr_table[0] == $cfg['Server']['pdf_pages']) {
|
||||||
$cfgRelation['pdf_pages'] = $curr_table[0];
|
$cfgRelation['pdf_pages'] = $curr_table[0];
|
||||||
}
|
}
|
||||||
}
|
} // end while
|
||||||
if(isset($cfgRelation['relation'])) {
|
if (isset($cfgRelation['relation'])) {
|
||||||
$cfgRelation['relwork'] = TRUE;
|
$cfgRelation['relwork'] = TRUE;
|
||||||
if(isset($cfgRelation['table_info'])) {
|
if (isset($cfgRelation['table_info'])) {
|
||||||
$cfgRelation['displaywork'] = TRUE;
|
$cfgRelation['displaywork'] = TRUE;
|
||||||
}
|
}
|
||||||
if(isset($cfgRelation['table_coords']) && isset($cfgRelation['pdf_pages'])) {
|
if (isset($cfgRelation['table_coords']) && isset($cfgRelation['pdf_pages'])) {
|
||||||
$cfgRelation['pdfwork'] = TRUE;
|
$cfgRelation['pdfwork'] = TRUE;
|
||||||
}
|
}
|
||||||
if(isset($cfgRelation['column_comments'])) {
|
if (isset($cfgRelation['column_comments'])) {
|
||||||
$cfgRelation['commwork'] = TRUE;
|
$cfgRelation['commwork'] = TRUE;
|
||||||
}
|
}
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
if ($tab_rs) {
|
||||||
|
mysql_free_result($tab_rs);
|
||||||
|
} else {
|
||||||
|
$cfg['Server']['pmadb'] = FALSE;
|
||||||
}
|
}
|
||||||
mysql_free_result($tab_rs);
|
|
||||||
return $cfgRelation;
|
return $cfgRelation;
|
||||||
} // end of the 'PMA_getRelationsParam()' function
|
} // end of the 'PMA_getRelationsParam()' function
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all Relations to foreign tables for a given table
|
* Gets all Relations to foreign tables for a given table or
|
||||||
* or optionally a given column in a table
|
* optionally a given column in a table
|
||||||
|
*
|
||||||
|
* @param string the name of the db to check for
|
||||||
|
* @param string the name of the table to check for
|
||||||
|
* @param string the name of the column to check for
|
||||||
*
|
*
|
||||||
* @return array db,table,column
|
* @return array db,table,column
|
||||||
*
|
*
|
||||||
* @global array the list of Relationsettings
|
* @global array the list of relations settings
|
||||||
|
* @global string the URL of the page to show in case of error
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
*
|
||||||
* @author Mike Beck <mikebeck@users.sourceforge.net>
|
* @author Mike Beck <mikebeck@users.sourceforge.net>
|
||||||
*/
|
*/
|
||||||
function getForeigners($db,$table,$column=FALSE) {
|
function PMA_getForeigners($db, $table, $column = '') {
|
||||||
global $cfgRelation, $err_url_0;
|
global $cfgRelation, $err_url_0;
|
||||||
|
|
||||||
$_rel_query = 'SELECT master_field, foreign_db,foreign_table,foreign_field'
|
$rel_query = 'SELECT master_field, foreign_db, foreign_table, foreign_field'
|
||||||
. ' FROM ' . PMA_backquote($cfgRelation['relation'])
|
. ' FROM ' . PMA_backquote($cfgRelation['relation'])
|
||||||
. ' WHERE master_db = \'' . $db . '\' '
|
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\' '
|
||||||
. ' AND master_table = \'' . $table . '\' ';
|
. ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\' ';
|
||||||
if(!empty($column)){
|
if (!empty($column)) {
|
||||||
$_rel_query .= ' AND master_field = \'' . $column . '\'';
|
$rel_query .= ' AND master_field = \'' . PMA_sqlAddslashes($column) . '\'';
|
||||||
}
|
}
|
||||||
$_relations = PMA_query_as_cu($_rel_query);
|
$relations = PMA_query_as_cu($rel_query);
|
||||||
$i=0;
|
$i = 0;
|
||||||
while ($relrow = @PMA_mysql_fetch_array($_relations)) {
|
while ($relrow = @PMA_mysql_fetch_array($relations)) {
|
||||||
$field = $relrow['master_field'];
|
$field = $relrow['master_field'];
|
||||||
$foreign[$field]['foreign_db'] = $relrow['foreign_db'];
|
$foreign[$field]['foreign_db'] = $relrow['foreign_db'];
|
||||||
$foreign[$field]['foreign_table'] = $relrow['foreign_table'];
|
$foreign[$field]['foreign_table'] = $relrow['foreign_table'];
|
||||||
$foreign[$field]['foreign_field'] = $relrow['foreign_field'];
|
$foreign[$field]['foreign_field'] = $relrow['foreign_field'];
|
||||||
$i++;
|
$i++;
|
||||||
} // end while
|
} // end while
|
||||||
if( isset($foreign) && is_array($foreign) ) {
|
|
||||||
|
if (isset($foreign) && is_array($foreign)) {
|
||||||
return $foreign;
|
return $foreign;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} // End function getForeigners
|
} // end of the 'PMA_getForeigners()' function
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the displayfield of a table
|
* Gets the display field of a table
|
||||||
* @return string fieldname
|
*
|
||||||
* @global array the list of Relationsettings
|
* @param string the name of the db to check for
|
||||||
* @access public
|
* @param string the name of the table to check for
|
||||||
* @author Mike Beck <mikebeck@users.sourceforge.net>
|
*
|
||||||
|
* @return string field name
|
||||||
|
*
|
||||||
|
* @global array the list of relations settings
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*
|
||||||
|
* @author Mike Beck <mikebeck@users.sourceforge.net>
|
||||||
*/
|
*/
|
||||||
function getDisplayField($db,$table) {
|
function PMA_getDisplayField($db, $table) {
|
||||||
global $cfgRelation;
|
global $cfgRelation;
|
||||||
$_disp_query = 'SELECT display_field FROM ' . PMA_backquote($cfgRelation['table_info'])
|
|
||||||
|
$disp_query = 'SELECT display_field FROM ' . PMA_backquote($cfgRelation['table_info'])
|
||||||
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
||||||
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
|
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
|
||||||
|
|
||||||
$_disp_res = PMA_query_as_cu($_disp_query);
|
$disp_res = PMA_query_as_cu($disp_query);
|
||||||
$row = ($_disp_res ? PMA_mysql_fetch_array($_disp_res) : '');
|
$row = ($disp_res ? PMA_mysql_fetch_array($disp_res) : '');
|
||||||
if (isset($row['display_field'])) {
|
if (isset($row['display_field'])) {
|
||||||
return $row['display_field'];
|
return $row['display_field'];
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
} // end of the 'PMA_getDisplayField()' function
|
||||||
/**
|
|
||||||
* Get the comments for all rows of a table
|
|
||||||
* @return arry [field_name] = comment
|
|
||||||
* @global array the list of Relationsettings
|
|
||||||
* @access public
|
|
||||||
* @author Mike Beck <mikebeck@users.sourceforge.net>
|
|
||||||
*/
|
|
||||||
function getComments($db,$table) {
|
|
||||||
global $cfgRelation;
|
|
||||||
$_com_qry = 'SELECT column_name,comment FROM ' . PMA_backquote($cfgRelation['column_comments'])
|
|
||||||
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
|
||||||
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
|
|
||||||
$_com_rs = PMA_query_as_cu($_com_qry);
|
|
||||||
while ($row = @PMA_mysql_fetch_array($_com_rs)) {
|
|
||||||
$col = $row['column_name'];
|
|
||||||
$comment[$col] = $row['comment'];
|
|
||||||
} // end while
|
|
||||||
|
|
||||||
if( isset($comment) && is_array($comment) ) {
|
|
||||||
|
/**
|
||||||
|
* Gets the comments for all rows of a table
|
||||||
|
*
|
||||||
|
* @param string the name of the db to check for
|
||||||
|
* @param string the name of the table to check for
|
||||||
|
*
|
||||||
|
* @return array [field_name] = comment
|
||||||
|
*
|
||||||
|
* @global array the list of relations settings
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*
|
||||||
|
* @author Mike Beck <mikebeck@users.sourceforge.net>
|
||||||
|
*/
|
||||||
|
function PMA_getComments($db, $table) {
|
||||||
|
global $cfgRelation;
|
||||||
|
|
||||||
|
$com_qry = 'SELECT column_name, comment FROM ' . PMA_backquote($cfgRelation['column_comments'])
|
||||||
|
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
||||||
|
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
|
||||||
|
$com_rs = PMA_query_as_cu($com_qry);
|
||||||
|
|
||||||
|
while ($row = @PMA_mysql_fetch_array($com_rs)) {
|
||||||
|
$col = $row['column_name'];
|
||||||
|
$comment[$col] = $row['comment'];
|
||||||
|
} // end while
|
||||||
|
|
||||||
|
if (isset($comment) && is_array($comment)) {
|
||||||
return $comment;
|
return $comment;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} // end function getComments
|
} // end of the 'PMA_getComments()' function
|
||||||
} // $__PMA_RELATION_LIB__INCLUDED
|
} // $__PMA_RELATION_LIB__
|
||||||
?>
|
?>
|
||||||
|
@@ -482,7 +482,7 @@ class PMA_RT_Table
|
|||||||
$this->y = (double) $this->y;
|
$this->y = (double) $this->y;
|
||||||
|
|
||||||
// displayfield
|
// displayfield
|
||||||
$this->displayfield = getDisplayField($db, $table_name);
|
$this->displayfield = PMA_getDisplayField($db, $table_name);
|
||||||
|
|
||||||
// index
|
// index
|
||||||
$sql = 'SHOW index FROM ' . PMA_backquote($table_name);
|
$sql = 'SHOW index FROM ' . PMA_backquote($table_name);
|
||||||
@@ -852,8 +852,8 @@ class PMA_RT
|
|||||||
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
||||||
. ' AND pdf_page_number = ' . $which_rel;
|
. ' AND pdf_page_number = ' . $which_rel;
|
||||||
$tab_rs = PMA_query_as_cu($tab_sql);
|
$tab_rs = PMA_query_as_cu($tab_sql);
|
||||||
if(!mysql_num_rows($tab_rs)>0){
|
if (!mysql_num_rows($tab_rs) > 0) {
|
||||||
die('no tables');
|
die('No tables');
|
||||||
}
|
}
|
||||||
while ($curr_table = @PMA_mysql_fetch_array($tab_rs)) {
|
while ($curr_table = @PMA_mysql_fetch_array($tab_rs)) {
|
||||||
$alltables[] = PMA_sqlAddslashes($curr_table['table_name']);
|
$alltables[] = PMA_sqlAddslashes($curr_table['table_name']);
|
||||||
@@ -867,25 +867,24 @@ class PMA_RT
|
|||||||
. ' AND foreign_table IN (' . $intable . ')';
|
. ' AND foreign_table IN (' . $intable . ')';
|
||||||
$result = PMA_query_as_cu($sql);
|
$result = PMA_query_as_cu($sql);
|
||||||
|
|
||||||
/*
|
// mikebeck: maybe we can show tables without relations if i comment
|
||||||
mikebeck: maybe we can show tables without relations if i comment that out
|
// that out
|
||||||
if (!$result || !mysql_num_rows($result)) {
|
// if (!$result || !mysql_num_rows($result)) {
|
||||||
$pdf->PMA_PDF_die($GLOBALS['strPdfInvalidPageNum']);
|
// $pdf->PMA_PDF_die($GLOBALS['strPdfInvalidPageNum']);
|
||||||
}
|
// }
|
||||||
*/
|
if (isset($result) && $result && mysql_num_rows($result) > 0) {
|
||||||
if(isset($result) && $result && mysql_num_rows($result)>0){
|
while ($row = PMA_mysql_fetch_array($result)) {
|
||||||
while ($row = PMA_mysql_fetch_array($result)) {
|
$this->PMA_RT_addRelation($row['master_table'] , $row['master_field'], $row['foreign_table'], $row['foreign_field']);
|
||||||
$this->PMA_RT_addRelation($row['master_table'] , $row['master_field'], $row['foreign_table'], $row['foreign_field']);
|
}
|
||||||
}
|
$norelations = FALSE;
|
||||||
$norelations=FALSE;
|
} else {
|
||||||
}else{
|
reset ($alltables);
|
||||||
reset ($alltables);
|
while (list(, $table) = each ($alltables)) {
|
||||||
while (list(, $table) = each ($alltables)) {
|
$this->tables[$table] = new PMA_RT_Table($table, $this->ff);
|
||||||
$this->tables[$table] = new PMA_RT_Table($table, $this->ff);
|
$this->PMA_RT_setMinMax($this->tables[$table]);
|
||||||
$this->PMA_RT_setMinMax($this->tables[$table]);
|
}
|
||||||
}
|
$norelations = TRUE;
|
||||||
$norelations=TRUE;
|
} // end if... else...
|
||||||
}
|
|
||||||
|
|
||||||
// Defines the scale factor
|
// Defines the scale factor
|
||||||
if ($scale == 'auto') {
|
if ($scale == 'auto') {
|
||||||
@@ -904,8 +903,8 @@ class PMA_RT
|
|||||||
$this->PMA_RT_strokeGrid();
|
$this->PMA_RT_strokeGrid();
|
||||||
}
|
}
|
||||||
$pdf->PMA_PDF_setFontSizeScale(14);
|
$pdf->PMA_PDF_setFontSizeScale(14);
|
||||||
if($norelations==FALSE){
|
if ($norelations == FALSE) {
|
||||||
$this->PMA_RT_drawRelations($change_color);
|
$this->PMA_RT_drawRelations($change_color);
|
||||||
}
|
}
|
||||||
$this->PMA_RT_drawTables($show_info);
|
$this->PMA_RT_drawTables($show_info);
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@ if (!isset($selected_tbl)) {
|
|||||||
require('./libraries/relation.lib.php3');
|
require('./libraries/relation.lib.php3');
|
||||||
$cfgRelation = PMA_getRelationsParam();
|
$cfgRelation = PMA_getRelationsParam();
|
||||||
if ($cfgRelation['commwork']) {
|
if ($cfgRelation['commwork']) {
|
||||||
$comments = getComments($db, $table);
|
$comments = PMA_getComments($db, $table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ while (list($key, $table) = each($the_tables)) {
|
|||||||
if ($cfgRelation['relation']) {
|
if ($cfgRelation['relation']) {
|
||||||
// Find which tables are related with the current one and write it in
|
// Find which tables are related with the current one and write it in
|
||||||
// an array
|
// an array
|
||||||
$res_rel = getForeigners($db, $table);
|
$res_rel = PMA_getForeigners($db, $table);
|
||||||
|
|
||||||
if (count($res_rel) > 0) {
|
if (count($res_rel) > 0) {
|
||||||
$have_rel = TRUE;
|
$have_rel = TRUE;
|
||||||
|
@@ -37,7 +37,6 @@ if ($table_info_num_rows > 0) {
|
|||||||
$att6 = '';
|
$att6 = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$lnk7 = "sql.php3";
|
|
||||||
$arg7 = ereg_replace('tbl_properties.php3$', 'db_details.php3', $url_query) . '&back=tbl_properties' . $sub_part . '.php3&reload=1&sql_query= ' . urlencode('DROP TABLE ' . PMA_backquote($table) ) . '&zero_rows=' . urlencode(sprintf($strTableHasBeenDropped, htmlspecialchars($table)));
|
$arg7 = ereg_replace('tbl_properties.php3$', 'db_details.php3', $url_query) . '&back=tbl_properties' . $sub_part . '.php3&reload=1&sql_query= ' . urlencode('DROP TABLE ' . PMA_backquote($table) ) . '&zero_rows=' . urlencode(sprintf($strTableHasBeenDropped, htmlspecialchars($table)));
|
||||||
$att7 = 'class="drop" onclick="return confirmLink(this, \'DROP TABLE ' . PMA_jsFormat($table) . '\')"';
|
$att7 = 'class="drop" onclick="return confirmLink(this, \'DROP TABLE ' . PMA_jsFormat($table) . '\')"';
|
||||||
|
|
||||||
|
@@ -296,7 +296,7 @@ if ($cfgRelation['relwork']) {
|
|||||||
// and $db is not the last of the list, because PMA_availableDatabases()
|
// and $db is not the last of the list, because PMA_availableDatabases()
|
||||||
// has made a PMA_mysql_select_db() on the last one
|
// has made a PMA_mysql_select_db() on the last one
|
||||||
PMA_mysql_select_db($db);
|
PMA_mysql_select_db($db);
|
||||||
$foreign = getForeigners($db, $table);
|
$foreign = PMA_getForeigners($db, $table);
|
||||||
|
|
||||||
if ($foreign) {
|
if ($foreign) {
|
||||||
?>
|
?>
|
||||||
|
@@ -22,10 +22,10 @@ $cfgRelation = PMA_getRelationsParam();
|
|||||||
* Updates
|
* Updates
|
||||||
*/
|
*/
|
||||||
if ($cfgRelation['relwork']) {
|
if ($cfgRelation['relwork']) {
|
||||||
$existrel = getForeigners($db, $table);
|
$existrel = PMA_getForeigners($db, $table);
|
||||||
}
|
}
|
||||||
if ($cfgRelation['displaywork']) {
|
if ($cfgRelation['displaywork']) {
|
||||||
$disp = getDisplayField($db, $table);
|
$disp = PMA_getDisplayField($db, $table);
|
||||||
}
|
}
|
||||||
if ($cfgRelation['relwork']
|
if ($cfgRelation['relwork']
|
||||||
&& isset($submit_rel) && $submit_rel == 'true') {
|
&& isset($submit_rel) && $submit_rel == 'true') {
|
||||||
@@ -124,13 +124,13 @@ if ($cfgRelation['commwork']
|
|||||||
|
|
||||||
// Now that we might have changed we have to see again
|
// Now that we might have changed we have to see again
|
||||||
if ($cfgRelation['relwork']) {
|
if ($cfgRelation['relwork']) {
|
||||||
$existrel = getForeigners($db, $table);
|
$existrel = PMA_getForeigners($db, $table);
|
||||||
}
|
}
|
||||||
if ($cfgRelation['displaywork']) {
|
if ($cfgRelation['displaywork']) {
|
||||||
$disp = getDisplayField($db, $table);
|
$disp = PMA_getDisplayField($db, $table);
|
||||||
}
|
}
|
||||||
if ($cfgRelation['commwork']) {
|
if ($cfgRelation['commwork']) {
|
||||||
$comments = getComments($db, $table);
|
$comments = PMA_getComments($db, $table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ if ($cfgRelation['relwork']) {
|
|||||||
} // end while
|
} // end while
|
||||||
|
|
||||||
// Create array of relations (Mike Beck)
|
// Create array of relations (Mike Beck)
|
||||||
$rel_dest = getForeigners($db, $table);
|
$rel_dest = PMA_getForeigners($db, $table);
|
||||||
} // end if
|
} // end if
|
||||||
|
|
||||||
// Now find out the columns of our $table
|
// Now find out the columns of our $table
|
||||||
@@ -241,7 +241,7 @@ if ($col_rs && mysql_num_rows($col_rs) > 0) {
|
|||||||
<?php
|
<?php
|
||||||
if ($cfgRelation['displaywork']) {
|
if ($cfgRelation['displaywork']) {
|
||||||
// Get "display_filed" infos
|
// Get "display_filed" infos
|
||||||
$disp = getDisplayField($db, $table);
|
$disp = PMA_getDisplayField($db, $table);
|
||||||
|
|
||||||
echo "\n";
|
echo "\n";
|
||||||
?>
|
?>
|
||||||
|
Reference in New Issue
Block a user