This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
The only this that I did was to add an entry to my array that had the lists, as the first item to say "All Airlines", or "All Departure Cities", then in my building of the criteriaString I made sure not to include the fields that had Al selected. Mark
i don't have my code with me, but here's roughly what i did: 1) first i tokenized the criteria string and put the key/value pairs into a hashtable, which is basically all my criteriaFind()'s duty. 2) then in another method, i go through the hashtable and grab the values out, if a value is "any"(ignore case), then i just ignore it, so for example, if you have "any" for carrier, "sfo" for origin and "any" for destination, i only need to find those DataInfo objects which have "sfo" as the origin from db.db. in another case, if all values are "any", just return all DataInfo objects.
Joined: Aug 27, 2001
forgot to say, i also have a criteria counter to check if all criteria have been matched. for example, if you have carrier, origin, destination, time(only for example), then before searching/returned any DataInfo objects, the counter should be 4, which means the no errors occur during the process of getting the criteria values. if you specify "any" for any of them, the counter will increment by one automatically, so i don't totally "ignore" it.
If the user select "Any, you don't need to include that field in the criteriaString passed to the criteriaFind method. example Airlines - Any Origin Airport SFX Arrival Airport Any your criteria string would be "Origin Airport = 'SFX'" there shouldn't need to have any of the other two fields in the string. Just my opinion too. Mark
Mark - What was your approach on 'Any Origin' and 'Any Destination'. Did you use Data.getRecord() or you implemented a wild card search in the Data.criteriaFind() ? I have implemented the later. -Rajesh
Like I said above, "any" was not passed or added to the criteria String in any way. No Pun there. Meaning I only would put a specific query if one existed. To quote myself
example Airlines - Any Origin Airport SFX Arrival Airport Any your criteria string would be "Origin Airport = 'SFX'"
So if, while looping through records, if the Origin Airport was "SFX" Then it was added to the found Hash. Mark
Joined: Feb 05, 2002
Sorry to reply to you lately. Actually, I meant implementing the search from ANY origin to ANY destination. I know it's easy to implement searching ANY origin or ANY destination. Do you really think it is appropriate to implement ANY to ANY search in criteriaFind()? I don't think so. criteriaFind() should be generic, and it should search for results with exact match. To implement ANY to ANY, I think it's just as simple as to get whole data records from database. So I agree with An Wang's approach. But, I'm not sure where to get it done. Should it be in criteriaFind() or some other method? Please comment. Thanks, Lijun
Joined: Aug 27, 2001
now i'm looking at my code. i have a private parseCriteria method to do the parsing, and then criteriaFind() to do the search. sorry i said criteriaFind() did the parsing earlier.
Joined: Jan 07, 2002
Mark - My question was actually on Airlines - Any Origin Airport Any Arrival Airport Any in which case your criterai will be empty and what is the result ?. -Rajesh