Find Query Quirks

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

Postby bobfelts » Tue May 15, 2007 6:15 pm

Hi,

When doing a Find on a test Db, I am getting some inconsistent behavior. One field is an enum field, which contains gender info, Male, Female, Decline. When I sort on Female, all works well. When I sort Male, I get both male and female record results. Should I avoid using an enum field to sort on?

Thanks,
Bob
bobfelts
 
Posts: 10
Joined: Wed Dec 31, 1969 5:00 pm

Postby bobfelts » Tue May 15, 2007 6:18 pm

Sorry, below are specifics regarding the install.

Version Dataface 0.7 dev 4
Ubantu Linux 6.06.1 LTS
FireFox 2.x
PHP5.1.2
MySQL 5.0.22-Debian_0ubuntu

Bob :|
bobfelts
 
Posts: 10
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Wed May 16, 2007 7:55 am

ENUM fields are fine for what you are trying to achieve.ÊÊ This is a bug related to the fact that dataface doesn't do exact matching by default - it does partial matching.Ê Hence It is searching for "male" which happens to match both "male" and "female".

Clearly it should do exact matching for enum fields by default.Ê To fix this problem, you can make a change to Dataface/SearchForm.php

On line 305 in my version it will have:

$qstr .= '&'.urlencode($key).'='.urlencode(implode( ' '.$op.' ', $value));

Change it to:

$qstr .= '&'.urlencode($key).'='.urlencode('='.implode( ' '.$op.' =', $value));

This will fix this behavior.

-Steve

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

Re: Find Query Quirks

Postby underwater » Thu Oct 20, 2011 7:47 am

Code: Select all
[column1]
widget:type = select
repeat = 1


=> $op = 'AND';
=> SELECT * FROM table_name WHERE column1 = 3 AND column1 = 5 AND column1 = 10
IMPOSSIBLE!

SELECT * FROM table_name WHERE column1 LIKE '%3%' AND column1 LIKE '%5%' AND column1 LIKE '%10%'
POSSIBLE

ANSER
Code: Select all
$eq = ($op == 'AND') ? '' : '=';
$qstr .= '&'.urlencode($key).'='.urlencode($eq.implode( ' '.$op.' '.$eq, $value));
underwater
 
Posts: 4
Joined: Sat Oct 15, 2011 1:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 15 guests

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