Find Query Quirks

Archived from the Xataface Users forum.

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 — 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


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


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));