[mapserver-users] generic way to access shape values from a query using phpmapscript

Daniel Morissette morissette at dmsolutions.ca
Wed Aug 7 12:32:12 PDT 2002


Sylvain Pasche wrote:
> 
> I want to display query results using php mapscript. For the moment,
> when I perform a query with msQueryByPoint, I get back a list of shape
> id using the resultcache. Then, when I want to access the values from
> the shape, I directly access the dbf on the disk to read the fields
> values.
> 
> This is ok for shapefile layers, but I would like to do the same with
> other kind of layer, such as opengis, ogr, and others.
> 
> Is there a way to do it with phpmapscript (ie: a generic way to read
> layer item values) and if so, how could this be done ?
> 

In PHP MapScript, the attribute (item) values are returned via a
shapeObj array property called values.

For instance, if your OGR data source contains a field called
"Population", then after a call to $shape = $layer->getShape() you can
access the Population attribute using:
   $shape->values["Population"]

Note that you can use print_r( $shape->values ) in PHP to dump the
content of the array and see what the attribute names are.

Daniel
-- 
------------------------------------------------------------
 Daniel Morissette               morissette at dmsolutions.ca
 DM Solutions Group              http://www.dmsolutions.ca/
------------------------------------------------------------
  Don't put for tomorrow what you can do today, because if 
      you enjoy it today you can do it again tomorrow.



More information about the MapServer-users mailing list