Hello!
Thanks to Alex, I have a possible MOD for DBMan 2.04 that will allow boolean AND/OR searching based on a flag bool=and or bool=or. If bool is not defined, then it performs a normal keyword search. But, I could use some help debugging it.
This code goes in db.cgi, in the sub query routine. Replace the code after:
# Now let's build up all the regexpressions we will use. This saves the program
# from having to recompile the same regular expression every time.
with:
($in{'bool'} eq 'and') ? ($bool = '&&') : ($bool = '| |'); # <-- NO space between the | |'s
foreach $field (@search_fields) {
$finalreg = '';
foreach my $word (split /\s/, $in{$db_cols[$field]}) {
next if ($word =~ /^\s*$/);
$tmpreg = $word;
(!$in{'re'}) and ($tmpreg = "\Q$tmpreg\E");
($in{'ww'}) and ($tmpreg = "\\b$tmpreg\\b");
(!$in{'cs'}) and ($tmpreg = "(?i)$tmpreg");
$finalreg .= " m/$tmpreg/o $bool";
}
if ($in{$db_cols[$field]} eq "*") {
$finalreg = "m/.*/";
}
else {
chop $finalreg; chop $finalreg;
}
$regexp_func[$field] = eval "sub { $finalreg }";
}
}
else {
foreach $field (@search_fields) {
my $tmpreg = "$in{$db_cols[$field]}";
(!$in{'re'}) and ($tmpreg = "\Q$tmpreg\E");
($in{'ww'}) and ($tmpreg = "^$tmpreg\$");
(!$in{'cs'}) and ($tmpreg = "(?i)$tmpreg");
($in{$db_cols[$field]} eq "*") and ($tmpreg = ".*"); # A "*" matches anything.
$regexp_func[$field] = eval "sub { m/$tmpreg/o }";
$regexp_bold[$field] = $tmpreg;
}
Any help getting this working would be seriously appreciated!!
----------------------------------------
Lee Leisure
HP Customer Relations Manager
----------------------------------------
* NOTE: This message is intended
for personal purposes only, and does
not imply the position or opinion of
the Hewlett Packard Company.
[This message has been edited by leisurelee (edited April 07, 2000).]
[This message has been edited by leisurelee (edited April 07, 2000).]
[This message has been edited by leisurelee (edited April 07, 2000).]
Thanks to Alex, I have a possible MOD for DBMan 2.04 that will allow boolean AND/OR searching based on a flag bool=and or bool=or. If bool is not defined, then it performs a normal keyword search. But, I could use some help debugging it.
This code goes in db.cgi, in the sub query routine. Replace the code after:
# Now let's build up all the regexpressions we will use. This saves the program
# from having to recompile the same regular expression every time.
with:
Quote:
if($in{'bool'}) { ($in{'bool'} eq 'and') ? ($bool = '&&') : ($bool = '| |'); # <-- NO space between the | |'s
foreach $field (@search_fields) {
$finalreg = '';
foreach my $word (split /\s/, $in{$db_cols[$field]}) {
next if ($word =~ /^\s*$/);
$tmpreg = $word;
(!$in{'re'}) and ($tmpreg = "\Q$tmpreg\E");
($in{'ww'}) and ($tmpreg = "\\b$tmpreg\\b");
(!$in{'cs'}) and ($tmpreg = "(?i)$tmpreg");
$finalreg .= " m/$tmpreg/o $bool";
}
if ($in{$db_cols[$field]} eq "*") {
$finalreg = "m/.*/";
}
else {
chop $finalreg; chop $finalreg;
}
$regexp_func[$field] = eval "sub { $finalreg }";
}
}
else {
foreach $field (@search_fields) {
my $tmpreg = "$in{$db_cols[$field]}";
(!$in{'re'}) and ($tmpreg = "\Q$tmpreg\E");
($in{'ww'}) and ($tmpreg = "^$tmpreg\$");
(!$in{'cs'}) and ($tmpreg = "(?i)$tmpreg");
($in{$db_cols[$field]} eq "*") and ($tmpreg = ".*"); # A "*" matches anything.
$regexp_func[$field] = eval "sub { m/$tmpreg/o }";
$regexp_bold[$field] = $tmpreg;
}
Any help getting this working would be seriously appreciated!!
----------------------------------------
Lee Leisure
HP Customer Relations Manager
----------------------------------------
* NOTE: This message is intended
for personal purposes only, and does
not imply the position or opinion of
the Hewlett Packard Company.
[This message has been edited by leisurelee (edited April 07, 2000).]
[This message has been edited by leisurelee (edited April 07, 2000).]
[This message has been edited by leisurelee (edited April 07, 2000).]