[Geomoose-users] GeoMoose Search on Multi Fields with Implode
Clause
Jim Dahl
jim.dahl at mail.co.douglas.mn.us
Wed May 23 13:53:17 EDT 2012
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<mailto:jim.dahl at mail.co.douglas.mn.us>>
To: "geomoose-users at lists.osgeo.org<mailto:geomoose-users at lists.osgeo.org>" <geomoose-users at lists.osgeo.org<mailto: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<mailto: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/7dd64e0d/attachment-0001.html
More information about the Geomoose-users
mailing list