Default query can contain field names (RFE #948590, patch #961726).

This commit is contained in:
Michal Čihař
2004-05-28 14:08:32 +00:00
parent 8ed5e573fc
commit 566d4b4f33
4 changed files with 20 additions and 13 deletions

View File

@@ -8,6 +8,8 @@ $Source$
2004-05-28 Michal Čihař <michal@cihar.com> 2004-05-28 Michal Čihař <michal@cihar.com>
* libraries/display_tbl.lib.php: Decrease limit for query truncating (see * libraries/display_tbl.lib.php: Decrease limit for query truncating (see
comments in bug #951744). comments in bug #951744).
* Documentation.html, config.inc.php, tbl_query_box.php: Default query can
contain field names (RFE #948590, patch #961726).
2004-05-26 Michal Čihař <michal@cihar.com> 2004-05-26 Michal Čihař <michal@cihar.com>
* lang/norwegian: Update, thanks to Sven-Erik Andersen - sven-erik. * lang/norwegian: Update, thanks to Sven-Erik Andersen - sven-erik.

View File

@@ -1834,11 +1834,12 @@ Defaults to FALSE (drop-down). <br />
<br /><br /> <br /><br />
</dd> </dd>
<dt><b>$cfg['DefaultQueryTable'] </b>string</dt> <dt><b>$cfg['DefaultQueryTable']</b> string</dt>
<dt><b>$cfg['DefaultQueryDatabase'] </b>string</dt> <dt><b>$cfg['DefaultQueryDatabase']</b> string</dt>
<dd> <dd>
Default query that will be displayed in query boxes, when user didn't Default queries that will be displayed in query boxes when user didn't
specify any. Use %d for database name and %t for table name. specify any. Use %d for database name, %t for table name and %f for a
comma separated list of field names.
<br /><br /> <br /><br />
</dd> </dd>

View File

@@ -532,12 +532,13 @@ $cfg['ReplaceHelpImg'] = TRUE; // show help button instead of strDocume
/** /**
* Default queries. * Default queries
* %d will be replaced by database name * %d will be replaced by the database name.
* %t will be replaced by table name * %t will be replaced by the table name.
* %f will be replaced by a list of field names.
*/ */
$cfg['DefaultQueryTable'] = 'SELECT * FROM %t WHERE 1'; $cfg['DefaultQueryTable'] = 'SELECT * FROM %t WHERE 1';
$cfg['DefaultQueryDatabase']= ''; $cfg['DefaultQueryDatabase'] = '';
/** /**
* SQL Query box settings * SQL Query box settings

View File

@@ -139,12 +139,15 @@ if (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE) {
<tr bgcolor="<?php echo $cfg['BgcolorOne']; ?>"> <tr bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
<td valign="top"><textarea name="sql_query" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE ? ceil($cfg['TextareaCols'] * 1.25) : $cfg['TextareaCols'] * 2); ?>" dir="<?php echo $text_dir; ?>"<?php echo $auto_sel; ?>> <td valign="top"><textarea name="sql_query" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE ? ceil($cfg['TextareaCols'] * 1.25) : $cfg['TextareaCols'] * 2); ?>" dir="<?php echo $text_dir; ?>"<?php echo $auto_sel; ?>>
<?php <?php
if (!empty($query_to_display)) { if (! empty($query_to_display)) {
echo htmlspecialchars($query_to_display); echo htmlspecialchars($query_to_display);
} elseif (isset($table)) {
echo htmlspecialchars(str_replace('%d', PMA_backquote($db), str_replace('%t', PMA_backquote($table), $cfg['DefaultQueryTable'])));
} else { } else {
echo htmlspecialchars(str_replace('%d', PMA_backquote($db), $cfg['DefaultQueryDatabase'])); $query = str_replace('%d', PMA_backquote($db), $cfg['DefaultQueryDatabase']);
if (isset($table)) {
$query = str_replace('%f', implode(', ', PMA_backquote($fields_list)), $cfg['DefaultQueryTable']);
$query = str_replace('%t', PMA_backquote($table), $query);
}
echo htmlspecialchars($query);
} }
?></textarea></td> ?></textarea></td>
<?php if (isset($table) && $fields_cnt > 0) { ?> <?php if (isset($table) && $fields_cnt > 0) { ?>