RFE #550552 - Default initial query, when a bookmarked query is available.

This commit is contained in:
Garvin Hicking
2003-03-12 20:20:32 +00:00
parent 9e89c6a994
commit e6d1ae755a
5 changed files with 26 additions and 9 deletions

View File

@@ -6,6 +6,9 @@ $Id$
$Source$ $Source$
2003-03-12 Garvin Hicking <me@supergarv.de> 2003-03-12 Garvin Hicking <me@supergarv.de>
* db_details_structure.php, left.php3, tbl_properties_links.php3, libraries/bookmark.lib.php3:
RFE #550552: Change default initial query for browse mode, if a bookmark with the same
label as the tablename is found.
* tbl_properties_options.php3, tbl_properties_table_info.php3: Support changing * tbl_properties_options.php3, tbl_properties_table_info.php3: Support changing
auto_increment value. (RFE #639655) auto_increment value. (RFE #639655)
* db_printview.php3, tbl_printview.php3, db_datadict.php3, pdf_schema.php3: * db_printview.php3, tbl_printview.php3, db_datadict.php3, pdf_schema.php3:

View File

@@ -129,9 +129,12 @@ else if (PMA_MYSQL_INT_VERSION >= 32303) {
</td> </td>
<td bgcolor="<?php echo $bgcolor; ?>"> <td bgcolor="<?php echo $bgcolor; ?>">
<?php <?php
include('./libraries/bookmark.lib.php3');
$book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
if (!empty($sts_data['Rows'])) { if (!empty($sts_data['Rows'])) {
echo '<a href="sql.php3?' . $tbl_url_query . '&amp;sql_query=' echo '<a href="sql.php3?' . $tbl_url_query . '&amp;sql_query='
. urlencode('SELECT * FROM ' . PMA_backquote($table)) . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table)))
. '&amp;pos=0">' . $strBrowse . '</a>'; . '&amp;pos=0">' . $strBrowse . '</a>';
} else { } else {
echo $strBrowse; echo $strBrowse;

View File

@@ -25,6 +25,7 @@ if ($cfg['OBGzip']) {
} }
} }
include('./libraries/bookmark.lib.php3');
require('./libraries/relation.lib.php3'); require('./libraries/relation.lib.php3');
$cfgRelation = PMA_getRelationsParam(); $cfgRelation = PMA_getRelationsParam();
@@ -247,9 +248,11 @@ if ($num_dbs > 1) {
: ''; : '';
echo "\n"; echo "\n";
$book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
?> ?>
<nobr><img src="images/spacer.gif" border="0" width="9" height="9" alt="" /> <nobr><img src="images/spacer.gif" border="0" width="9" height="9" alt="" />
<a target="phpmain" href="sql.php3?<?php echo $common_url_query; ?>&amp;table=<?php echo urlencode($table); ?>&amp;sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&amp;pos=0&amp;goto=<?php echo $cfg['DefaultTabTable']; ?>" title="<?php echo $strBrowse . ': ' . $url_title; ?>"> <a target="phpmain" href="sql.php3?<?php echo $common_url_query; ?>&amp;table=<?php echo urlencode($table); ?>&amp;sql_query=<?php echo (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))); ?>&amp;pos=0&amp;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; ?>">&nbsp;</bdo> <img src="images/browse.png" width="8" height="8" border="0" alt="<?php echo $strBrowse . ': ' . $url_title; ?>" /></a><bdo dir="<?php echo $text_dir; ?>">&nbsp;</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; ?>&amp;table=<?php echo urlencode($table); ?>"> <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; ?>&amp;table=<?php echo urlencode($table); ?>">
<?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br /> <?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br />
@@ -280,7 +283,9 @@ if ($num_dbs > 1) {
? str_replace('"', '&quot;', $tooltip_name[$table]) ? str_replace('"', '&quot;', $tooltip_name[$table])
: ''; : '';
$table_list .= ' <nobr><a target="phpmain" href="sql.php3?' . $common_url_query . '&amp;table=' . urlencode($table) . '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($table)) . '&amp;pos=0&amp;goto=' . $cfg['DefaultTabTable'] . '">' . "\n"; $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
$table_list .= ' <nobr><a target="phpmain" href="sql.php3?' . $common_url_query . '&amp;table=' . urlencode($table) . '&amp;sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&amp;pos=0&amp;goto=' . $cfg['DefaultTabTable'] . '">' . "\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 . '">&nbsp;</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 . '">&nbsp;</bdo>' . "\n";
if (PMA_USR_BROWSER_AGENT == 'IE') { 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 . '&amp;table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : 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 . '&amp;table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></span></nobr><br />' . "\n";
@@ -408,9 +413,11 @@ else if ($num_dbs == 1) {
$url_title = (!empty($tooltip) && isset($tooltip[$table])) $url_title = (!empty($tooltip) && isset($tooltip[$table]))
? str_replace('"', '&quot;', $tooltip[$table]) ? str_replace('"', '&quot;', $tooltip[$table])
: ''; : '';
$book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
echo "\n"; echo "\n";
?> ?>
<nobr><a target="phpmain" href="sql.php3?<?php echo $common_url_query; ?>&amp;table=<?php echo urlencode($table); ?>&amp;sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&amp;pos=0&amp;goto=<?php echo $cfg['DefaultTabTable']; ?>" title="<?php echo $strBrowse . ': ' . htmlspecialchars($table); ?>"> <nobr><a target="phpmain" href="sql.php3?<?php echo $common_url_query; ?>&amp;table=<?php echo urlencode($table); ?>&amp;sql_query=<?php echo (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))); ?>&amp;pos=0&amp;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; ?>">&nbsp;</bdo> <img src="images/browse.png" width="8" height="8" border="0" alt="<?php echo $strBrowse . ': ' . htmlspecialchars($table); ?>" /></a><bdo dir="<?php echo $text_dir; ?>">&nbsp;</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; ?>&amp;table=<?php echo urlencode($table); ?>"> <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; ?>&amp;table=<?php echo urlencode($table); ?>">
<?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br /> <?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br />

View File

@@ -81,24 +81,25 @@ if (!defined('PMA_BOOKMARK_LIB_INCLUDED')) {
* *
* @param string the current database name * @param string the current database name
* @param array the bookmark parameters for the current user * @param array the bookmark parameters for the current user
* @param integer the id of the bookmark to get * @param mixed the id of the bookmark to get
* @param string which field to look up the $id
* *
* @return string the sql query * @return string the sql query
* *
* @access public * @access public
*/ */
function PMA_queryBookmarks($db, $cfgBookmark, $id) function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id')
{ {
$query = 'SELECT query FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table']) $query = 'SELECT query FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\'' . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\'' . ' AND user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
. ' AND id = ' . $id; . ' AND ' . PMA_backquote($id_field) . ' = ' . $id;
if (isset($GLOBALS['dbh'])) { if (isset($GLOBALS['dbh'])) {
$result = PMA_mysql_query($query, $GLOBALS['dbh']); $result = PMA_mysql_query($query, $GLOBALS['dbh']);
} else { } else {
$result = PMA_mysql_query($query); $result = PMA_mysql_query($query);
} }
$bookmark_query = PMA_mysql_result($result, 0, 'query'); $bookmark_query = @PMA_mysql_result($result, 0, 'query') OR FALSE;
return $bookmark_query; return $bookmark_query;
} // end of the 'PMA_queryBookmarks()' function } // end of the 'PMA_queryBookmarks()' function

View File

@@ -18,10 +18,13 @@ $db_details_links_count_tabs = 0;
/** /**
* Prepares links * Prepares links
*/ */
include('./libraries/bookmark.lib.php3');
$book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
if ($table_info_num_rows > 0) { if ($table_info_num_rows > 0) {
$lnk2 = 'sql.php3'; $lnk2 = 'sql.php3';
$arg2 = $url_query $arg2 = $url_query
. '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($table)) . '&amp;sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table)))
. '&amp;pos=0'; . '&amp;pos=0';
$lnk4 = 'tbl_select.php3'; $lnk4 = 'tbl_select.php3';
$arg4 = $url_query; $arg4 = $url_query;