[Mapserver-users] Performing queries with GDAL/OGR and PHPMapScript

Daniel Morissette morissette at dmsolutions.ca
Thu Jul 24 12:29:52 PDT 2003


Franck Martin wrote:
> 
> What I see in the PHPMapscript is that the script returns the ID of the 
> object selected. In the case of mysql ,postgis, DBF, the drivers are 
> built inside php, so accessing the full record is not a problem.  But in 
> the case of layers connected via OGR (like MapInfo tables), How do I 
> access the full record?
> It seems that the mapserver is accessing all the fields of a record via 
> OGR when it needs for instance to label objects. But it seems to me that 
> this API does not exists in PHPMapScript.
> 

You have access to all the attributes of a shape read via OGR using the 
$shape->values[] array.  This is briefly explained in the PHP MapScript 
docs:


----------------8<------------------
ShapeObj Class:
  --------------

  Members:

    string  text
    int     classindex
    int     type      (read-only)
    int     numlines  (read-only)
    int     index     (read-only)
    int     tileindex (read-only)
    rectObj bounds    (read-only)
    int     numvalues (read-only)
    array   values    (read-only)

    The values array is an associative array with the attribute values for
    this shape.  It is set only on shapes obtained from layer->getShape().
    The key to the values in the array is the attribute name, e.g.
      $population = $shape->values["Population"];

---------------->8------------------

-- 
------------------------------------------------------------
  Daniel Morissette               morissette at dmsolutions.ca
  DM Solutions Group              http://www.dmsolutions.ca/
------------------------------------------------------------




More information about the MapServer-users mailing list