Display and enter DB/table comments for navigation, stored in pma comments
table. May be displayed as Alias-Tooltips in left frame. [#650064]
This commit is contained in:
@@ -31,7 +31,12 @@ if (empty($is_info)) {
|
||||
require('./libraries/relation.lib.php3');
|
||||
$cfgRelation = PMA_getRelationsParam();
|
||||
|
||||
|
||||
/**
|
||||
* Check if comments were updated
|
||||
*/
|
||||
if ($cfgRelation['commwork'] && isset($db_comment) && $db_comment == 'true') {
|
||||
PMA_SetComment($db, '', '(db_comment)', $comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the tables list
|
||||
@@ -48,6 +53,34 @@ if ($num_tables == 0) {
|
||||
|
||||
// 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
|
||||
else if (PMA_MYSQL_INT_VERSION >= 32303) {
|
||||
|
||||
// Get additional information about tables for tooltip
|
||||
if ($cfg['ShowTooltip']) {
|
||||
$tooltip_truename = array();
|
||||
$tooltip_aliasname = array();
|
||||
|
||||
$result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
|
||||
while ($tmp = PMA_mysql_fetch_array($result)) {
|
||||
$tooltip_truename[$tmp['Name']] = ($cfg['ShowTooltipAliasTB'] ? (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '') : $tmp['Name']);
|
||||
$tooltip_aliasname[$tmp['Name']] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : ''));
|
||||
} // end while
|
||||
} // end if
|
||||
|
||||
if ($cfgRelation['commwork']) {
|
||||
$comment = PMA_getComments($db);
|
||||
|
||||
/**
|
||||
* Displays table comment
|
||||
*/
|
||||
if (is_array($comment)) {
|
||||
?>
|
||||
<!-- DB comment -->
|
||||
<p><i>
|
||||
<?php echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?>
|
||||
</i></p>
|
||||
<?php
|
||||
} // end if
|
||||
}
|
||||
?>
|
||||
<form method="post" action="db_details_structure.php3" name="tablesForm">
|
||||
<?php echo PMA_generate_common_hidden_inputs($db); ?>
|
||||
@@ -75,6 +108,13 @@ else if (PMA_MYSQL_INT_VERSION >= 32303) {
|
||||
$table_encoded = urlencode($table);
|
||||
$table_name = htmlspecialchars($table);
|
||||
|
||||
$alias = (!empty($tooltip_aliasname) && isset($tooltip_aliasname[$table]))
|
||||
? str_replace('"', '"', $tooltip_aliasname[$table])
|
||||
: htmlspecialchars($sts_data['Name']);
|
||||
$truename = (!empty($tooltip_truename) && isset($tooltip_truename[$table]))
|
||||
? str_replace('"', '"', $tooltip_truename[$table])
|
||||
: htmlspecialchars($sts_data['Name']);
|
||||
|
||||
// Sets parameters for links
|
||||
$tbl_url_query = $url_query . '&table=' . $table_encoded;
|
||||
$bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
|
||||
@@ -85,7 +125,7 @@ else if (PMA_MYSQL_INT_VERSION >= 32303) {
|
||||
<input type="checkbox" name="selected_tbl[]" value="<?php echo $table_encoded; ?>" id="checkbox_tbl_<?php echo $i; ?>"<?php echo $checked; ?> />
|
||||
</td>
|
||||
<td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
|
||||
<b><label for="checkbox_tbl_<?php echo $i; ?>"><?php echo $table_name; ?></label> </b>
|
||||
<b><label for="checkbox_tbl_<?php echo $i; ?>" title="<?php echo $alias; ?>"><?php echo $truename; ?></label> </b>
|
||||
</td>
|
||||
<td bgcolor="<?php echo $bgcolor; ?>">
|
||||
<?php
|
||||
@@ -315,6 +355,22 @@ else if (PMA_MYSQL_INT_VERSION >= 32303) {
|
||||
|
||||
// 3. Shows tables list mysql < 3.23.03
|
||||
else {
|
||||
if ($cfgRelation['commwork']) {
|
||||
$comment = PMA_getComments($db);
|
||||
|
||||
/**
|
||||
* Displays table comment
|
||||
*/
|
||||
if (is_array($comment)) {
|
||||
?>
|
||||
<!-- DB comment -->
|
||||
<p><i>
|
||||
<?php echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?>
|
||||
</i></p>
|
||||
<?php
|
||||
} // end if
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
echo "\n";
|
||||
?>
|
||||
@@ -428,6 +484,23 @@ if ($num_tables > 0) {
|
||||
</li>
|
||||
<?php
|
||||
} // end if
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ($cfgRelation['commwork']) {
|
||||
?>
|
||||
<!-- Alter/Enter db-comment -->
|
||||
<li>
|
||||
<form method="post" action="db_details_structure.php3">
|
||||
<?php echo $strDBComment; ?>
|
||||
<input type="hidden" name="db_comment" value="true" />
|
||||
<?php echo PMA_generate_common_hidden_inputs($db); ?>
|
||||
<input type="text" name="comment" class="textfield" value="<?php echo (is_array($comment) ? htmlspecialchars(implode(' ', $comment)) : ''); ?>" />
|
||||
<input type="submit" value="<?php echo $strGo; ?>" />
|
||||
</form>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Create a new table -->
|
||||
|
67
left.php3
67
left.php3
@@ -25,6 +25,8 @@ if ($cfg['OBGzip']) {
|
||||
}
|
||||
}
|
||||
|
||||
require('./libraries/relation.lib.php3');
|
||||
$cfgRelation = PMA_getRelationsParam();
|
||||
|
||||
/**
|
||||
* Get the list and number of available databases.
|
||||
@@ -224,18 +226,31 @@ if ($num_dbs > 1) {
|
||||
$num_tables_disp = '-';
|
||||
}
|
||||
|
||||
// Get additional infomation about tables for tooltip
|
||||
// Get additional information about tables for tooltip
|
||||
if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
|
||||
&& $num_tables
|
||||
&& (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
|
||||
$tooltip = array();
|
||||
$tooltip_name = array();
|
||||
$result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
|
||||
while ($tmp = PMA_mysql_fetch_array($result)) {
|
||||
$tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
|
||||
$tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
|
||||
|
||||
$tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
|
||||
. '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
|
||||
} // end while
|
||||
} // end if
|
||||
|
||||
// garvin: Get comments from PMA comments table
|
||||
$db_tooltip = '';
|
||||
if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
|
||||
$tmp_db_tooltip = PMA_getComments($db);
|
||||
if (is_array($tmp_db_tooltip)) {
|
||||
$db_tooltip = implode(' ', $tmp_db_tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
// No light mode -> displays the expandible/collapsible db list
|
||||
if ($cfg['LeftFrameLight'] == FALSE) {
|
||||
|
||||
@@ -259,8 +274,8 @@ if ($num_dbs > 1) {
|
||||
}
|
||||
echo "\n";
|
||||
?>
|
||||
<a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick="if (capable) {expandBase('el<?php echo $j; ?>', false)}">
|
||||
<span class="heada"><?php echo htmlspecialchars($db); ?><bdo dir="<?php echo($text_dir); ?>"> </bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
|
||||
<a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" title="<?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db) : htmlspecialchars($db_tooltip)); ?>" onclick="if (capable) {expandBase('el<?php echo $j; ?>', false)}">
|
||||
<span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? '<i>' . htmlspecialchars($db_tooltip) . '</i>' : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>"> </bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
|
||||
</div>
|
||||
|
||||
<div id="el<?php echo $j;?>Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
|
||||
@@ -269,16 +284,20 @@ if ($num_dbs > 1) {
|
||||
// Displays the list of tables from the current database
|
||||
for ($t = 0; $t < $num_tables; $t++) {
|
||||
$table = PMA_mysql_tablename($tables, $t);
|
||||
$alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
|
||||
? htmlspecialchars($tooltip_name[$table])
|
||||
: '';
|
||||
$url_title = (!empty($tooltip) && isset($tooltip[$table]))
|
||||
? htmlspecialchars($tooltip[$table])
|
||||
: '';
|
||||
|
||||
echo "\n";
|
||||
?>
|
||||
<nobr><img src="images/spacer.gif" border="0" width="9" height="9" alt="" />
|
||||
<a target="phpmain" href="sql.php3?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&pos=0&goto=<?php echo $cfg['DefaultTabTable']; ?>" title="<?php echo $strBrowse . ': ' . htmlspecialchars($table); ?>">
|
||||
<img src="images/browse.png" width="8" height="8" border="0" alt="<?php echo $strBrowse . ': ' . htmlspecialchars($table); ?>" /></a><bdo dir="<?php echo $text_dir; ?>"> </bdo>
|
||||
<a target="phpmain" href="sql.php3?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&pos=0&goto=<?php echo $cfg['DefaultTabTable']; ?>" title="<?php echo $strBrowse . ': ' . $url_title; ?>">
|
||||
<img src="images/browse.png" width="8" height="8" border="0" alt="<?php echo $strBrowse . ': ' . $url_title; ?>" /></a><bdo dir="<?php echo $text_dir; ?>"> </bdo>
|
||||
<a class="tblItem" id="tbl_<?php echo md5($table); ?>" title="<?php echo $url_title; ?>" target="phpmain" href="<?php echo $cfg['DefaultTabTable']; ?>?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>">
|
||||
<?php echo htmlspecialchars($table); ?></a></nobr><br />
|
||||
<?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br />
|
||||
<?php
|
||||
} // end for $t (tables list)
|
||||
echo "\n";
|
||||
@@ -302,12 +321,16 @@ if ($num_dbs > 1) {
|
||||
$url_title = (!empty($tooltip) && isset($tooltip[$table]))
|
||||
? str_replace('"', '"', $tooltip[$table])
|
||||
: '';
|
||||
$alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
|
||||
? str_replace('"', '"', $tooltip_name[$table])
|
||||
: '';
|
||||
|
||||
$table_list .= ' <nobr><a target="phpmain" href="sql.php3?' . $common_url_query . '&table=' . urlencode($table) . '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($table)) . '&pos=0&goto=' . $cfg['DefaultTabTable'] . '">' . "\n";
|
||||
$table_list .= ' <img src="images/browse.png" width="8" height="8" border="0" alt="' . $strBrowse . ': ' . $table . '" title="' . $strBrowse . ': ' . htmlspecialchars($table) . '" /></a><bdo dir="' . $text_dir . '"> </bdo>' . "\n";
|
||||
$table_list .= ' <img src="images/browse.png" width="8" height="8" border="0" alt="' . $strBrowse . ': ' . $url_title . '" title="' . $strBrowse . ': ' . $url_title . '" /></a><bdo dir="' . $text_dir . '"> </bdo>' . "\n";
|
||||
if (PMA_USR_BROWSER_AGENT == 'IE') {
|
||||
$table_list .= ' <span class="tblItem"><a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . htmlspecialchars($table) . '</a></span></nobr><br />' . "\n";
|
||||
$table_list .= ' <span class="tblItem"><a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></span></nobr><br />' . "\n";
|
||||
} else {
|
||||
$table_list .= ' <a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . htmlspecialchars($table) . '</a></nobr><br />' . "\n";
|
||||
$table_list .= ' <a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n";
|
||||
}
|
||||
} // end for $t (tables list)
|
||||
|
||||
@@ -318,15 +341,15 @@ if ($num_dbs > 1) {
|
||||
$selected = ' selected="selected"';
|
||||
|
||||
$table_list_header .= ' <a class="item" target="phpmain" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
|
||||
$table_list_header .= ' <span class="heada"><b>' . htmlspecialchars($db) . '</b><bdo dir="' . $text_dir . '"> </bdo></span></a><br />' . "\n\n";
|
||||
$table_list_header .= ' <span class="heada"><b>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasTB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . '</b><bdo dir="' . $text_dir . '"> </bdo></span></a><br />' . "\n\n";
|
||||
} else {
|
||||
$selected = '';
|
||||
} // end if... else...
|
||||
|
||||
if (!empty($num_tables)) {
|
||||
echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . htmlspecialchars($db) . ' (' . $num_tables . ')</option>' . "\n";
|
||||
echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
|
||||
} else {
|
||||
echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . htmlspecialchars($db) . ' (-)</option>' . "\n";
|
||||
echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
|
||||
} // end if... else...
|
||||
|
||||
} // end if (light mode)
|
||||
@@ -392,25 +415,41 @@ else if ($num_dbs == 1) {
|
||||
if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
|
||||
&& $num_tables) {
|
||||
$tooltip = array();
|
||||
$tooltip_name = array();
|
||||
$result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
|
||||
while ($tmp = PMA_mysql_fetch_array($result)) {
|
||||
$tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
|
||||
$tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
|
||||
|
||||
$tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
|
||||
. '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
|
||||
} // end while
|
||||
} // end if
|
||||
|
||||
// garvin: Get comments from PMA comments table
|
||||
$db_tooltip = '';
|
||||
if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
|
||||
$tmp_db_tooltip = PMA_getComments($db);
|
||||
if (is_array($tmp_db_tooltip)) {
|
||||
$db_tooltip = implode(' ', $tmp_db_tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
// Displays the database name
|
||||
echo "\n";
|
||||
?>
|
||||
<div id="el2Parent" class="parent">
|
||||
<nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
|
||||
<span class="heada"><?php echo htmlspecialchars($db); ?><bdo dir="<?php echo($text_dir); ?>"> </bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
|
||||
<span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>"> </bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
|
||||
</div>
|
||||
<div id="el2Child" class="child" style="margin-bottom: 5px">
|
||||
<?php
|
||||
// Displays the list of tables from the current database
|
||||
for ($j = 0; $j < $num_tables; $j++) {
|
||||
$table = PMA_mysql_tablename($tables, $j);
|
||||
$alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
|
||||
? str_replace('"', '"', $tooltip_name[$table])
|
||||
: '';
|
||||
$url_title = (!empty($tooltip) && isset($tooltip[$table]))
|
||||
? str_replace('"', '"', $tooltip[$table])
|
||||
: '';
|
||||
@@ -419,7 +458,7 @@ else if ($num_dbs == 1) {
|
||||
<nobr><a target="phpmain" href="sql.php3?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&pos=0&goto=<?php echo $cfg['DefaultTabTable']; ?>" title="<?php echo $strBrowse . ': ' . htmlspecialchars($table); ?>">
|
||||
<img src="images/browse.png" width="8" height="8" border="0" alt="<?php echo $strBrowse . ': ' . htmlspecialchars($table); ?>" /></a><bdo dir="<?php echo $text_dir; ?>"> </bdo>
|
||||
<a class="tblItem" id="tbl_<?php echo md5($table); ?>" title="<?php echo $url_title; ?>" target="phpmain" href="<?php echo $cfg['DefaultTabTable']; ?>?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>">
|
||||
<?php echo htmlspecialchars($table); ?></a></nobr><br />
|
||||
<?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br />
|
||||
<?php
|
||||
} // end for $j (tables list)
|
||||
echo "\n";
|
||||
|
@@ -294,17 +294,31 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){
|
||||
*
|
||||
* @author Mike Beck <mikebeck@users.sourceforge.net>
|
||||
*/
|
||||
function PMA_getComments($db, $table) {
|
||||
function PMA_getComments($db, $table = '') {
|
||||
global $cfgRelation;
|
||||
|
||||
if ($table != '') {
|
||||
$com_qry = 'SELECT column_name, ' . PMA_backquote('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);
|
||||
} else {
|
||||
$com_qry = 'SELECT comment FROM ' . PMA_backquote($cfgRelation['column_comments'])
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
||||
. ' AND table_name = \'\''
|
||||
. ' AND column_name = \'(db_comment)\'';
|
||||
$com_rs = PMA_query_as_cu($com_qry);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while ($row = @PMA_mysql_fetch_array($com_rs)) {
|
||||
$col = $row['column_name'];
|
||||
$i++;
|
||||
$col = ($table != '' ? $row['column_name'] : $i);
|
||||
|
||||
if (strlen($row['comment']) > 0) {
|
||||
$comment[$col] = $row['comment'];
|
||||
}
|
||||
|
||||
} // end while
|
||||
|
||||
if (isset($comment) && is_array($comment)) {
|
||||
@@ -313,5 +327,85 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){
|
||||
return FALSE;
|
||||
}
|
||||
} // end of the 'PMA_getComments()' function
|
||||
|
||||
/**
|
||||
* Adds/removes slashes if required
|
||||
*
|
||||
* @param string the string to slash
|
||||
*
|
||||
* @return string the slashed string
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PMA_handleSlashes($val) {
|
||||
return (get_magic_quotes_gpc() ? str_replace('\\"', '"', $val) : PMA_sqlAddslashes($val));
|
||||
} // end of the "PMA_handleSlashes()" function
|
||||
|
||||
/**
|
||||
* Set a single comment to a certain value.
|
||||
*
|
||||
* @param string the name of the db
|
||||
* @param string the name of the table
|
||||
* @param string the name of the column
|
||||
* @param string the value of the column
|
||||
* @param string (optional) if a column is renamed, this is the name of the former key which will get deleted
|
||||
*
|
||||
* @return boolean true, if comment-query was made.
|
||||
*
|
||||
* @global array the list of relations settings
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PMA_setComment($db, $table, $key, $value, $removekey = '') {
|
||||
global $cfgRelation;
|
||||
|
||||
if ($removekey != '' AND $removekey != $key) {
|
||||
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_comments'])
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
||||
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
|
||||
. ' AND column_name = \'' . PMA_handleSlashes($removekey) . '\'';
|
||||
$rmv_rs = PMA_query_as_cu($remove_query);
|
||||
unset($rmv_query);
|
||||
}
|
||||
|
||||
$test_qry = 'SELECT ' . PMA_backquote('comment') . ', mimetype, transformation, transformation_options FROM ' . PMA_backquote($cfgRelation['column_comments'])
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
||||
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
|
||||
. ' AND column_name = \'' . PMA_handleSlashes($key) . '\'';
|
||||
$test_rs = PMA_query_as_cu($test_qry);
|
||||
|
||||
if ($test_rs && mysql_num_rows($test_rs) > 0) {
|
||||
$row = @PMA_mysql_fetch_array($test_rs);
|
||||
|
||||
if (strlen($value) > 0 || strlen($row['mimetype']) > 0 || strlen($row['transformation']) > 0 || strlen($row['transformation_options']) > 0) {
|
||||
$upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_comments'])
|
||||
. ' SET ' . PMA_backquote('comment') . ' = \'' . PMA_handleSlashes($value) . '\''
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
||||
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
|
||||
. ' AND column_name = \'' . PMA_handleSlashes($key) . '\'';
|
||||
} else {
|
||||
$upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_comments'])
|
||||
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
||||
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
|
||||
. ' AND column_name = \'' . PMA_handleSlashes($key) . '\'';
|
||||
}
|
||||
} else if (strlen($value) > 0) {
|
||||
$upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['column_comments'])
|
||||
. ' (db_name, table_name, column_name, ' . PMA_backquote('comment') . ') '
|
||||
. ' VALUES('
|
||||
. '\'' . PMA_sqlAddslashes($db) . '\','
|
||||
. '\'' . PMA_sqlAddslashes($table) . '\','
|
||||
. '\'' . PMA_handleSlashes($key) . '\','
|
||||
. '\'' . PMA_handleSlashes($value) . '\')';
|
||||
}
|
||||
|
||||
if (isset($upd_query)){
|
||||
$upd_rs = PMA_query_as_cu($upd_query);
|
||||
unset($upd_query);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} // end of 'PMA_setComment()' function
|
||||
} // $__PMA_RELATION_LIB__
|
||||
?>
|
||||
|
Reference in New Issue
Block a user