Two straight-ahead search questions.

A place for users and developers of the Xataface to discuss and receive support.

Postby shiraz » Thu Jan 11, 2007 7:06 pm

Good day!

I have two simple search questions:

1. Is there a way to search for null values in a given field? Or can I search with a negative operand?

2. I have a drop-down field that I want to search. I want to be able to search for all values above a given number. But since it's a dropdown, I can't actually enter "> 1" to search all values greater than one. I need to choose just one value from the list. Is there anything I can do here? Could I perhaps do a calculated field based on the drop-down and make the calculated field searchable? Or if I can't make a calculated field searchable I could add a delegate class to copy the drop-down field and make *that* field searchable, but I'd also want to make it non-editable. Is that possible?


Thanks to anyone who can answer!

Shiraz
shiraz
 
Posts: 55
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Fri Jan 12, 2007 1:45 pm

Good point, I can't think of a clean way to change the find form to accommodate this, but the guts of dataface will certainly allow this sort of search. Dataface searching works on URLs and GET parameters. Suppose your field name is 'category'. By adding "category=1..5" as a GET parameter
e.g. http://yourdomain.com/yourapp/index.php?-table=foo&-action=list&category=1..5
You will get all of the records with category values between 1 and 5
Similarly you could do:
"category=>1"
"category=<1"
For greater than or less than searches.

Now, the auto-generated search form doesn't currently allow you to change the widget type on the form, but you can rig up your own little form to do this search if you like. All it has to do is append to the GET parameters.

Alternatively, you can whip up some tricky javascript code to change the widget type in the DOM with about 3 lines of code if you wanted to.

Hope this helps a little.

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby shiraz » Fri Jan 12, 2007 2:45 pm

That does help, thanks again Steve!
shiraz
 
Posts: 55
Joined: Wed Dec 31, 1969 5:00 pm

Postby shiraz » Fri Jan 12, 2007 3:14 pm

Steve, I'm not sure you answered the 1st question. Is there something I could put as a GET parameter to specify a null value? And/or, a NOT EQUALS? eg. "if studenttypetrainee" or "if studenttype==NULL"
shiraz
 
Posts: 55
Joined: Wed Dec 31, 1969 5:00 pm

Postby shiraz » Mon Jan 15, 2007 7:14 am

My apologies for not doing this before, but I just upgraded to version 0.69 (from 0.53) and I see the find form has been improved -- including the addition of the NONE radio button beside any of the drop-down fields. Sweet!


HOWEVER! It appears checking the NONE value for a drop-down list only matches empty strings, which are treated differently by MySQL than NULL fields. NULL fields are *not* matched when this box is checked. In fact, NULL fields are the default value for an empty field in a standard MySQL table, which essentially makes this a Dataface bug. I may be wrong but I believe this is correct. I suspect you missed it Steve because perhaps Dataface-inserted records set empty fields to an empty string rather than leaving them NULL? I haven't checked that but it seems logical.


And HOWEVER #2! I'm wondering how I might specify a NULL search criteria for a free-form field. Perhaps the NONE radio button should be available for all fields, not just the drop-downs.



Version .69 is a BLESSING! Thanks again, Mr. Hannah.
shiraz
 
Posts: 55
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Mon Jan 15, 2007 12:39 pm

I Shiraz,

Looks like you are right. The searching does not deal with NULL values at all. I'll have to add this for the next release.

As far as ways to specify "NOT EQUALS", you can either begin the search term with '!=' or ''.

E.g. if you want to find records that do not have DOG in the "subject" field, you would put 'DOG' in the search field for "subject" (or '!=DOG').

Best regards

Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby shiraz » Wed Jan 17, 2007 5:27 pm

Thanks Steve!
shiraz
 
Posts: 55
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 19 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved