Re: Search with an Array
Re: Search with an Array
- Subject: Re: Search with an Array
- From: james o <email@hidden>
- Date: Tue, 6 Jan 2004 18:07:23 -0500
i think i've made something similar to what you're looking for.
-create an NSArray of the check box items - searchList
["book","dog","health","etc"]
-iterate through searchList and fetch rows from your DB.
-within each iteration add the returning array to an NSMutableArray
example:
resultList = new NSMutableArray();
for (int i=0; i<searchList.count(); i++){
//get search string from checkbox list... each item is selected with
objectAtIndex(i)
searchString =
(String)(searchList.objectAtIndex(i)).valueForKey("someStringFromCheckBo
xList");
// construct arguments
NSMutableArray args = new NSMutableArray();
args.addObject(searchString);
//create qualifier
qualifier = EOQualifier.qualifierWithQualifierFormat ("dbColumn = %@",
args);
EOFetchSpecification fetchSpec = new
EOFetchSpecification("SomeTableClass", qualifier, null);
//optional way to create qualifier
// EOQualifier qualifier = EOQualifier.qualifierWithQualifierFormat
("lastName = 'Smith'", null);
// grab a new NSArray with the above fetchSpec
NSArray tempList = new
NSArray(editingContext.objectsWithFetchSpecification(fetchSpec));
// add results from this list to resultList
if ( tempList.count() > ) resultList.addObjectsFromArray(tempList);
}
i haven't checked any of this code. use it as an example and replace
your vars accordingly.
hth,
./james
{ WOCode.com : WebObjects source code - frameworks - examples - links :
http://WOCode.com }
On Jan 5, 2004, at 1:46 AM, Owen McKerrow wrote:
Hi All,
I have a feedback table, which has a many to many relationship with a
descriptors table ( single words that can be assigned to a feedback
item to help describe it e.g. book, dog, health )
I wish to search through my feedback items via descriptors. That is I
wish to be able to select an number of descriptors ( probably using a
Checkbox matrix ) and then ask the DB for all feedback items that are
related to any of the descriptors chosen. I have never done a search
like this before ( i.e. using an array of items to search over ) and
was wondering what is the best way to do it ?
Thanks
Owen McKerrow
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.