Re: [mapserver-users] queryByAttributes syntax
Thanks, I'll try this. Berend On 1/22/10, Lime, Steve D (DNR) wrote: > 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-boun...@lists.osgeo.org > [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Berend > Veldkamp > Sent: Friday, January 22, 2010 6:22 AM > To: mapserver-users@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 > ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] queryByAttributes syntax
Thanks, but that's exactly the kind of thing I'd like to prevent... On 1/24/10, Worth Lutz wrote: > I use the layer.connectiontype to adjust my query calls. > > > > Connection Types > > MS_INLINE, MS_SHAPEFILE, MS_TILED_SHAPEFILE, MS_SDE, MS_OGR, MS_TILED_OGR, > MS_POSTGIS, MS_WMS, MS_ORACLESPATIAL, MS_WFS, MS_GRATICULE, MS_MYGIS, > MS_RASTER, MS_PLUGIN > > > > > > For example: > > > > If layer.connectiontype == MS_SHAPEFILE) { > >layer.queryByAttributes(map, "myfield", "searchValue", > mapscript.MS_MULTIPLE); > > } else { > >layer.queryByAttributes(map, null, "myfield='searchValue'", > mapscript.MS_MULTIPLE); > > } > > > > _ > > From: mapserver-users-boun...@lists.osgeo.org > [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Berend > Veldkamp > Sent: Friday, January 22, 2010 7:22 AM > To: mapserver-users@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 > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 9.0.730 / Virus Database: 271.1.1/2640 - Release Date: 01/23/10 > 02:33:00 > > ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
RE: [mapserver-users] queryByAttributes syntax
I use the layer.connectiontype to adjust my query calls. Connection Types MS_INLINE, MS_SHAPEFILE, MS_TILED_SHAPEFILE, MS_SDE, MS_OGR, MS_TILED_OGR, MS_POSTGIS, MS_WMS, MS_ORACLESPATIAL, MS_WFS, MS_GRATICULE, MS_MYGIS, MS_RASTER, MS_PLUGIN For example: If layer.connectiontype == MS_SHAPEFILE) { layer.queryByAttributes(map, "myfield", "searchValue", mapscript.MS_MULTIPLE); } else { layer.queryByAttributes(map, null, "myfield='searchValue'", mapscript.MS_MULTIPLE); } _ From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Berend Veldkamp Sent: Friday, January 22, 2010 7:22 AM To: mapserver-users@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 No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.730 / Virus Database: 271.1.1/2640 - Release Date: 01/23/10 02:33:00 ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
RE: [mapserver-users] queryByAttributes syntax
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-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Berend Veldkamp Sent: Friday, January 22, 2010 6:22 AM To: mapserver-users@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 ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users