[Geomoose-users] GeoMoose Search on Multi Fields with Implode Clause

Dan Little danlittle at yahoo.com
Wed May 23 14:13:06 EDT 2012


isset - checks to see if the value has been set from the CGI call.  It's a damned goofy PHP thing.  The != "" means "not an empty string."

But you still need the wildcards for partial matching with like.  If you're looking for exact matches than use "=" in the SQL.

And JimK, your suspicion is correct, MapServer filters doesn't allow for bind values without my patches for it (which may or may not be in the 6.0 code, I need to check again, same with table checking code).

EliA, I believe JimD is using a substantially older version of GeoMOOSE with a custom PHP service.  




>________________________________
> From: Jim Dahl <jim.dahl at mail.co.douglas.mn.us>
>To: Dan Little <danlittle at yahoo.com>; "geomoose-users at lists.osgeo.org" <geomoose-users at lists.osgeo.org> 
>Sent: Wednesday, May 23, 2012 12:53 PM
>Subject: RE: [Geomoose-users] GeoMoose Search on Multi Fields with Implode Clause
> 
>
> 
>Dan, I am not sure what the isset does and the != “” must be saying to ignore the field if there are no entries?  Anyway, I get no results on any searches
> 
>if($field3 == "HNUM" and isset($searchval3) and $searchval3 != "") {
>array_push($clauses, "HNUM like '".$searchval3."'");
>}
> 
>From:Dan Little [mailto:danlittle at yahoo.com] 
>Sent: Wednesday, May 23, 2012 12:15 PM
>To: Jim Dahl; geomoose-users at lists.osgeo.org
>Subject: Re: [Geomoose-users] GeoMoose Search on Multi Fields with Implode Clause
> 
>Wouldn't it be easier to simply check if a value is set?
> 
>IE:
> 
>if($field3 == "HOUSE" and isset($searval3) and $searchval3 != "") {
> ... add the clause
>}
> 
>That way you don't have an extra SQL bits. The extraneous "OR"s would just serve to confuse the database.
> 
>>
>>________________________________
>> 
>>From:Jim Dahl <jim.dahl at mail.co.douglas.mn.us>
>>To: "geomoose-users at lists.osgeo.org" <geomoose-users at lists.osgeo.org> 
>>Sent: Wednesday, May 23, 2012 8:40 AM
>>Subject: [Geomoose-users] GeoMoose Search on Multi Fields with Implode Clause
>> 
>>I have need to search on multiple fields and the following code works if I have a wildcard in all of the fields.  If I take out a wildcard and do not enter anything in that field, the result is nothing found.  Probably because the empty field doesn’t match the database for any entries.  So what I would like to do is Make and OR with the field without a wild card and the other fields that have the AND.  Hope this makes sense to someone.  I credit Dan with the code for the implode clauses and it works great with the criteria of wild cards or have a pull down in the field that contains all the possible entries.  HNUM is the field I would like to not have the wildcard.  I have as many as ten fields, but show fewer for this example.  THANKS.
>> 
>> 
>>$clauses = array();
>> 
>>if($field3 == "HNUM") {
>>array_push($clauses, "HNUM like '".$searchval3."'");
>>}
>> 
>>if($field4 == "STREET") {
>>array_push($clauses, "STREET like '%".$searchval4."%'");
>>}
>> 
>>if($field5 == "CITY") {
>>array_push($clauses, "CITY like '%".$searchval5."%'");
>>}
>> 
>>$all_clauses = implode(" AND ", $clauses);
>> 
>>$rs = $conn->Execute("SELECT * FROM housenum WHERE ".$all_clauses." ORDER BY ".$sort." ASC");
>> 
>>Jim Dahl, GISP
>>GIS Coordinator
>>Douglas County Public Works
>>526 Willow Dr
>>PO Box 398
>>Alexandria MN 56308
>> 
>>V 320-762-2933
>>   320-762-2999
>>F 320-762-2998
>> 
>>
>>_______________________________________________
>>Geomoose-users mailing list
>>Geomoose-users at lists.osgeo.org
>>http://lists.osgeo.org/mailman/listinfo/geomoose-users
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geomoose-users/attachments/20120523/eb9ae3d8/attachment.html


More information about the Geomoose-users mailing list