Gossamer Forum
Home : Products : DBMan : Customization :

All + Any search

(Page 1 of 2)
> >
Quote Reply
All + Any search
Hi, can't get enough of that DBman.. Tongue

I'm having trouble with that normal search (not the keyword).

Is it possible to do a All search (all the fields must be correct), where there is no value checked at the search options, along with a Any search in it?

for example:

(name=john)&&(age=23)&&(country=(canada)or(usa))

Thanks.
Quote Reply
Re: [alon_g] All + Any search In reply to
A normal search using the search options is a keyword search.

What you would want to do is to create a custom search form. There are some examples within the DBMan FAQ noted below under the section "Searching".

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/
Quote Reply
Re: [LoisC] All + Any search In reply to
Just a small fix in the line above: what I want is more od something like that:

(name=john)&&(age=23)&&((country=canada)or(sex=male))

Will the custom search still do the job for me?
Quote Reply
Re: [alon_g] All + Any search In reply to
I don't think dbman can be used to do this.

The script can tie any number of search fields together with "and", or with "or", but not some of the fields with "and" and others with "or", which is what you want.
kellner
Quote Reply
Re: [kellner] All + Any search In reply to
Let me explain why I need this, and id anyone has an idea for me, it'll be great:






My database contains soccer matches of the israeli national team. in every match, there is a field for the home team, and a field for the guest team. Therefore, in every game I have ISRAEL in either home team or guest team. The problem is that when a user perform a search, he only need to write the the opponent team and not israel, so I need to search both of the fields.

So I've put the home team field available to write on, and the on submit, his content is being copied to a hidden guest team field, and the are both being searched using ANY search.

This works fine, but if I want for example to search for opponent USA and year 1999, that is not possible, because it's both ANY and ALL search.




Does anyone have an idea for me?

Thanks, Alon Gal.
Quote Reply
Re: [alon_g] All + Any search In reply to
I understood what you wanted allright, but there's no way to make dbman do this on a general scale. It's just not coded that way.

If this is a search that you will use very often, you could hardcode a special search routine just for these fields and for this database.
kellner
Quote Reply
Re: [kellner] All + Any search In reply to
Thanks kellner - I have a new idea to solve this thing.

Is it possible to make an IF statement before the search goes through each game, that says -
  • if the home team is ISRAEL - search the opponent on away team field.
  • if the away team is ISRAEL - search the opponent on home team field.


Tell me what you think..
Quote Reply
Re: [alon_g] All + Any search In reply to
You can hardcode this particular search - no problem. But you can't (at least I wouldn't know how) modify dbman's search routine to do such searches on a general scale.
kellner
Quote Reply
Re: [kellner] All + Any search In reply to
What exactly do you mean by Hardcore the search?
Quote Reply
Re: [alon_g] All + Any search In reply to
hardcode, not hardcore Wink

What I mean is: you would have to write an extra perl routine which performs ONLY this particular search.
kellner
Quote Reply
Re: [kellner] All + Any search In reply to
LOL Blush

Thanks kellner.
Quote Reply
Re: [alon_g] All + Any search In reply to
I still don't see why a custom search form would not provide you with the search results you are looking for. This is how I narrow down searches for all databases.

For example you could setup your custom search form something like this:

<TABLE border=0 cellpadding=2 cellspacing=0 width=460>
<TR><TD><$font>Name:</font></TD><TD><input type="TEXT" name="Name" SIZE="30" VALUE="$rec{'Name'}"></TD></TR>
<TR><TD><$font>Age:</font></TD><TD><input type="TEXT" name="Age" SIZE="25" VALUE="$rec{'Age'}"></TD></TR>
<TR><TD><$font>Country:</font></TD><TD><input type="TEXT" name="Country" SIZE="25" VALUE="$rec{'Country'}"></TD></TR>
<TR><TD><$font>Year: </FONT></TD><TD><TD>|; print &build_select_field_from_db("Year",$rec{'Year'}); print qq|</TD></TR>
<TR><TD><$font>Home Team: </FONT></TD><TD><TD>|; print &build_select_field_from_db("Home Team",$rec{'Home Team'}); print qq|</TD></TR>
<TR><TD><$font>Home Team: </FONT></TD><TD><TD>|; print &build_select_field_from_db("Guest Team",$rec{'Guest Team'}); print qq|</TD></TR>
</TABLE>

There are other examples in the FAQ.

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/
Quote Reply
Re: [LoisC] All + Any search In reply to
Hey Lois,

I still don't understand what the custom search is, and what does the fields with print &build_select_field_from_db("Year",$rec{'Year'}); do.

I've read this but I don't get it.. http://webmagic.hypermart.net/.../db/text/search7.txt

Can you explain to me what this means and how can I do my desired search with it?

Thanks.
Quote Reply
Re: [alon_g] All + Any search In reply to
A custom search form will enable you to only display the field you choose to search within, unlike a keyword search.

print &build_select_field_from_db("Year",$rec{'Year'});

work to display the actual options within the database. This way people don't have to enter for instance a year which is not within the database and get an error message. Instead they can choose from the option that are actually within the database records.

I think if you set it up and tried it you would get a better idea of what it does. You can also test the search form withn the FAQ to see how that custom search form works.

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/
Quote Reply
Re: [LoisC] All + Any search In reply to
Oh, so this basiclly just turns the search from a free keyword search to a select box with the available options. It's a good idea for the search but I can't see how it could cover my problem: I want to search records that fits ALL the terms, but the team selected in hometeam will be in either hometeam or guestteam. Tell me if I didn't get you right.

Thanks for your patience.
Quote Reply
Re: [kellner] All + Any search In reply to
Hi again Kellner,

Is there any way you think you can write the needed code for me? I do need this for 2 particular searches, so the harcode options is the only one for me.

Please - if you can help me in any way - I'm really desperate with this one.

Thanks, Alon Gal.
Quote Reply
Re: [alon_g] All + Any search In reply to
Sorry, I can't help you out on this one, am too busy with other things at the moment.
kellner
Quote Reply
Re: [kellner] All + Any search In reply to
Ok, I wan't bother you Unimpressed

Well, just one more time Wink

If I want to make an If statement that will change the search values before each game is checked can I write it below this?
Code:
# Normal searches.
$key_match = 0;
If you have any example code of a similar thing you made once - that will be very helpful..

And I anyone else can help me I would appreciate it very much.. 10x
Quote Reply
Re: [alon_g] All + Any search In reply to
There may be another way if you cannot figure out the hardcode in Perl. I don't think I could Perl code it without some major effort.

So perhaps here is a nice "sloppy" way to do it.

If your first problem is ... searching for a TEAM (a record) within both HOME and AWAY (fields), then maybe you should just create an additional field which is the combination of HOME and AWAY. Make sure wholeword is off, then you can make match any off. Am I correct here? Anybody? Opinions welcome!

If the second problem is that ... when match any is on, searches for a team/year combination return too many results, then turn off the match any as per above.

Optionally the search pages could be generated from separate html pages. That is a user would select the type of search first. If you wanted to create a search page for each team, then the user would select a team from a html list of links. For each team create a search page that passes the the team variable by default or hidden.

DBman Can do it, so can U. Sly
Quote Reply
Re: [joematt] All + Any search In reply to
Hello joematt, thanks so much for trying to help.

The second solution is not good for me - I have the hall search ready except for this field and it's not possible for me to make a link for each team..

I didn't really understand your first one (additional field which is the combination of HOME and AWAY). Basically I need to search for a certain TEAM in one of the fields (HOME/AWAY).

My idea is to tell the script before he check a certain game, that if ISRAEL is the hometeam in this game - compare the input team to the AWAY TEAM - same with the opposite.

Tell me what you think about this and if your solution can do this.

Thanks again!
Quote Reply
Re: [alon_g] All + Any search In reply to
Regarding
Quote:
I didn't really understand your first one
let me try to explain. let's say you have 4 games,


see text file sloppy.txt


To find games where Israel played at home, search within HOME, should find 2 games.

To find games where Isreal played home or away, search within HOMEAWAY1, and make sure wholeword is off. Should find 4 games.

To find games where Israel played the USA, search within HOMEAWAY1 for Israel and within HOMEAWAY2 for USA. Should return 2 games.

Now I know this is really getting messy

Blush

but I think you could generate HOMEAWAY1 and HOMEAWAY2 as variables, without really having them in the database.
Try searching the forum for "concatenate" as that's what I think this combining is called.

Sorry I am not the Perl expert.

I know that once DBman starts a search you cannot easily interupt the search based on the content of a record, which is what you seem to suggest.

Quote:
My idea is to tell the script before he check a certain game, that if ISRAEL is the hometeam in this game -
compare the input team to the AWAY TEAM - same with the opposite.
Quote Reply
Re: [joematt] All + Any search In reply to
Hello again Joe,

Your idea is really good (and creative - I must say) - but I don't think I can perform this. It could work good with the team field, but I also have the players field (soccer - what can you do Wink) which is a long textarea, and i'm not sure it'll work there. Tell me what you think..

* Maybe we can first search without that term and then search the search results with a simple ANY search? I didn't find a mod for this thing..

Can't give up on that one.. Unsure

Last edited by:

alon_g: Jul 23, 2002, 11:59 AM
Quote Reply
Re: [joematt] All + Any search In reply to
Hey,

I decided to start working on your idea since it's really good, and this is what I have so far (note that instead of teams I'm talking about players now - should be the same):

I added to every record in the DB 2 empty field named homeplayer & awayplayer. Now when someone searched the db, he write a name of a player in a field named homeplayer. when he submits the form what he wrote there is being copied to the hidden awayplayer field.

So now we have the search for example: homeplayer=ronaldo, awayplayer=ronaldo.

Now I went to db.cgi where the search opens each record in sub_query below this:
Code:
$key_match = 0;
foreach $field (@search_fields) {
and wrote this concatenate code, to make homeplayer & awayplayer both teams' player list.
Code:
$in{'homeplayer'} = $db_cols[13] . " " . $db_cols[18];
$in{'awayplayer'} = $db_cols[13] . " " . $db_cols[18];
But instead of field #13's value - I got his name (the one stated in the CFG file). I also tried this method:
Code:
$in{'homeplayer'} = $in{"$db_cols[13]"} . " " . $in{"$db_cols[18]"};
But with this I got nothing.

How can I get the actual value of the field?
Quote Reply
Re: [alon_g] All + Any search In reply to
Yes creative is a good word for it.

It occurred to me that with the WholeWord=off search option you can get extra records from a search that you did not want. Such as a team called "US" found within a team called "Russia". May not be a problem for teams as they can be made distinct (and probably a pull down list of teams is better than asking the user to splell the team name exactly the same way as in the database).

For Players, there may be too many overlapping names that the wholeword=off might give bogus results.

Regarding searching within search results, this I too would like to be able to do, but have not looked for a MOD nor tried to produce it. I'm pretty sure it has been done, but not as a MOD.

EDIT BELOW

I looked through my DBman files and found some modifications I had done and did not recall doing, Hum?
Send me an email and I could send some sections from my db.cgi and html.pl that show what I did. I can't promomise I even understand what the code does, or where it came from, I think it was trial and error and some help from Paul and Kellner ....????

FYI these are modifications that start with the CATEGORIES mods, and then enable the list of categories (links) to search for the same term in multiple fields (but not all) without matchany = on. Thus I think you could find a player or a team name within HOMe or AWAY etc.

I knew your problem sounded familiar, Just could not recall the answer. This is the application.

http://www.herbicide-adjuvants.com/adjprod-type.htm

Last edited by:

joematt: Jul 25, 2002, 8:30 AM
Quote Reply
Re: [alon_g] All + Any search In reply to
Glad you found the concatenate code;

try using eg instead of =

try removing the blank spaces before and after the .

try single quotes and not double quotes

These are just guesses, sorry.

Last edited by:

joematt: Jul 25, 2002, 7:50 AM
> >