[mapserver-users] queryByAttributes syntax
Lime, Steve D (DNR)
Steve.Lime at state.mn.us
Fri Jan 22 11:09:07 PST 2010
There's a single way to call the method, it's that you don't always have to supply the query item. The method signature is
queryByAttributes (map (mapObj, qitem (string), qstring (string), mode (int));
The qstring is given in a format compatible with the underlying driver. For the database drivers it's basically a where-clause. For others
you use MapServer expression syntax. Some expression types (e.g. string matches or regex) require the qitem.
To do a partial match you could use a regex, for example:
layer.queryByAttributes(map, "myfield", "/myregex/", mapscript.MS_MULTIPLE);
Steve
From: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Berend Veldkamp
Sent: Friday, January 22, 2010 6:22 AM
To: mapserver-users at lists.osgeo.org
Subject: [mapserver-users] queryByAttributes syntax
Hi,
Where can I find more information about the queryByAttributes() function? I found http://mapserver.org/mapscript/php/index.html#layerobj-class , but it is not very detailed. By trial and error I found that for a PostGIS layer, I should use this syntax:
layer.queryByAttributes(map, null, "myfield='searchValue'", mapscript.MS_MULTIPLE);
but for shapefiles, it seems it should be:
layer.queryByAttributes(map, "myfield", "searchValue", mapscript.MS_MULTIPLE);
I am trying to write some generic code, but that's hard if there is no single way to call this method. Also, I haven't found a way yet to do a partial match on a shapefile (PostGIS supports 'LIKE')
Regards,
Berend Veldkamp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20100122/dd677140/attachment.htm>
More information about the MapServer-users
mailing list