move search operators to config

This commit is contained in:
Marc Delisle
2004-08-17 12:37:37 +00:00
parent 8f3c3accec
commit 2102df6073
5 changed files with 97 additions and 24 deletions

View File

@@ -5,6 +5,12 @@ phpMyAdmin - Changelog
$Id$
$Source$
2004-08-17 Marc Delisle <lem9@users.sourceforge.net>
* tbl_select.php, config.inc.php, libraries/config_import.lib.php,
libraries/common.lib.php: move search operators to config file,
and set "LIKE" as default operator instead of "LIKE %...%", for
performance reasons
2004-08-16 Alexander M. Turek <me@derrabus.de>
* libraries/relation.lib.php: Fixed some collation problems with the
relational tables (bug #995359).

View File

@@ -655,7 +655,7 @@ $cfg['ColumnTypes'] = array(
'SET'
);
// Atributes
// Attributes
$cfg['AttributeTypes'] = array(
'',
'BINARY',
@@ -778,6 +778,42 @@ if ($cfg['ShowFunctionFields']) {
} // end if
// Search operators
$cfg['NumOperators'] = array(
'=',
'>',
'>=',
'<',
'<=',
'!=',
'LIKE',
'NOT LIKE'
);
$cfg['TextOperators'] = array(
'LIKE',
'LIKE %...%',
'NOT LIKE',
'=',
'!=',
'REGEXP',
'NOT REGEXP'
);
$cfg['EnumOperators'] = array(
'=',
'!='
);
$cfg['NullOperators'] = array(
'IS NULL',
'IS NOT NULL'
);
$cfg['UnaryOperators'] = array(
'IS NULL' => 1,
'IS NOT NULL' => 1
);
/**
* Unset magic_quotes_runtime - do not change!

View File

@@ -142,7 +142,7 @@ if (isset($cfg['FileRevision'])) {
} else {
$cfg['FileRevision'] = array(1, 1);
}
if ($cfg['FileRevision'][0] < 2 || ($cfg['FileRevision'][0] == 2 && $cfg['FileRevision'][1] < 36)) {
if ($cfg['FileRevision'][0] < 2 || ($cfg['FileRevision'][0] == 2 && $cfg['FileRevision'][1] < 38)) {
require_once('./libraries/config_import.lib.php');
}

View File

@@ -1046,6 +1046,52 @@ if ($cfg['ShowFunctionFields']) {
}
}
if (!isset($cfg['NumOperators'])) {
$cfg['NumOperators'] = array(
'=',
'>',
'>=',
'<',
'<=',
'!=',
'LIKE',
'NOT LIKE'
);
}
if (!isset($cfg['TextOperators'])) {
$cfg['TextOperators'] = array(
'LIKE',
'LIKE %...%',
'NOT LIKE',
'=',
'!=',
'REGEXP',
'NOT REGEXP'
);
}
if (!isset($cfg['EnumOperators'])) {
$cfg['EnumOperators'] = array(
'=',
'!='
);
}
if (!isset($cfg['NullOperators'])) {
$cfg['NullOperators'] = array(
'IS NULL',
'IS NOT NULL'
);
}
if (!isset($cfg['UnaryOperators'])) {
$cfg['UnaryOperators'] = array(
'IS NULL' => 1,
'IS NOT NULL' => 1
);
}
if (!isset($cfg['GD2Available'])) {
$cfg['GD2Available'] = 'auto';
}

View File

@@ -30,20 +30,6 @@ if ($cfg['PropertiesIconic'] == true) {
$titles['Browse'] = $strBrowseForeignValues;
}
/**
* Defines arrays of functions (should possibly be in config.inc.php
* so it can also be used in tbl_qbe.php)
*
* LIKE works also on integers and dates so I added it in numfunctions
*/
$numfunctions = array('=', '>', '>=', '<', '<=', '!=', 'LIKE', 'NOT LIKE');
$textfunctions = array('LIKE %...%','LIKE', 'NOT LIKE', '=', '!=', 'REGEXP', 'NOT REGEXP');
$enumfunctions = array('=', '!=');
$nullfunctions = array('IS NULL', 'IS NOT NULL');
$unaryfunctions = array(
'IS NULL' => 1,
'IS NOT NULL' => 1);
/**
* Not selection yet required -> displays the selection form
*/
@@ -103,8 +89,8 @@ if (!isset($param) || $param[0] == '') {
function PMA_tbl_select_operator(f, index, multiple) {
switch (f.elements["func[" + index + "]"].options[f.elements["func[" + index + "]"].selectedIndex].value) {
<?php
reset($unaryfunctions);
while (list($operator) = each($unaryfunctions)) {
reset($GLOBALS['cfg']['UnaryOperators']);
while (list($operator) = each($GLOBALS['cfg']['UnaryOperators'])) {
echo ' case "' . $operator . "\":\r\n";
}
?>
@@ -242,23 +228,23 @@ function PMA_tbl_select_operator(f, index, multiple) {
<select name="func[]">
<?php
if (strncasecmp($fields_type[$i], 'enum', 4) == 0) {
foreach ($enumfunctions as $k => $fc) {
foreach ($GLOBALS['cfg']['EnumOperators'] as $k => $fc) {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '">' . htmlspecialchars($fc) . '</option>';
}
} elseif (preg_match('@char|blob|text|set@i', $fields_type[$i])) {
foreach ($textfunctions as $k => $fc) {
foreach ($GLOBALS['cfg']['TextOperators'] as $k => $fc) {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '">' . htmlspecialchars($fc) . '</option>';
}
} else {
foreach ($numfunctions as $k => $fc) {
foreach ($GLOBALS['cfg']['NumOperators'] as $k => $fc) {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '">' . htmlspecialchars($fc) . '</option>';
}
} // end if... else...
if ($fields_null[$i]) {
foreach ($nullfunctions as $k => $fc) {
foreach ($GLOBALS['cfg']['NullOperators'] as $k => $fc) {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '">' . htmlspecialchars($fc) . '</option>';
}
@@ -369,7 +355,7 @@ else {
$cnt_func = count($func);
reset($func);
while (list($i, $func_type) = each($func)) {
if (@$unaryfunctions[$func_type] == 1) {
if (@$GLOBALS['cfg']['UnaryOperators'][$func_type] == 1) {
$fields[$i] = '';
$w[] = PMA_backquote(urldecode($names[$i])) . ' ' . $func_type;
@@ -426,7 +412,6 @@ else {
if ($orderField != '--nil--') {
$sql_query .= ' ORDER BY ' . PMA_backquote(urldecode($orderField)) . ' ' . $order;
} // end if
include('./sql.php');
}