[mapserver-users] php mapscript
Alan Boudreault
aboudreault at mapgears.com
Thu Mar 25 06:32:08 PDT 2010
Sven,
getShape() is deprecated. Use rather getFeature(). I suggest to also take a
look at the nextShape() function:
http://mapserver.org/mapscript/php/index.html#layerobj-class
Alan
On March 25, 2010 09:18:50 am Sven Schroeter wrote:
> Hi,
> I have an old php mapscript code that works fine with mapserver 5.02 or
> 5.2, but not with 5.6.1.
> The code runs an attribute tabe from a postgis layer and different querys
> i.e. queryByRect:
>
> ...
> @$datQuery = $query_layer->queryByRect($qRect);
>
> //number of objects
> $resnum = $query_layer->getNumResults();
> echo "number of objects: ".$resnum."<br>";
>
> //if query success
> if ($datQuery == MS_SUCCESS) {
> $query_layer->open();
>
> //first row
> $result = $query_layer->getResult(0);
> $shpobj = $query_layer->getShape($result->tileindex,$result->shapeindex);
> //read attribute
> $attr = $shpobj->values;
>
> //write headline
> echo '<table cellspacing="0" cellpadding="2" border="1" ><tr>';
> foreach($attr as $name=>$wert) {
> echo '<td bgcolor="#CCCCCC">'.$name.'</td>';
> }
> echo '</tr>';
>
> //write datasets
> for ($j=0; $j<$query_layer->getNumResults(); $j++) {
> $result = $query_layer->getResult($j);
> $shpobj =
> $query_layer->getShape($result->tileindex,$result->shapeindex); $ri =
> $result->tileindex;
> $si = $result->shapeindex;
> $attr = $shpobj->values;
> echo '<tr id="row'.$si.'" >';
> foreach($attr as $name=>$wert) {
> echo '<td>'.$wert.'</td>';
> }
> echo '</tr>';
> $shpobj->free();
> }
> $query_layer->close();
> echo '</table>';
>
> } // end success
> ...
>
> In ms 5.6.1 the query is also successful (I get the correct number of
> objects) but there comes following warning:
> Invalid argument supplied for foreach() in ... Fatal error: Call to a
> member function free() on a non-object in ...
> No object? Why? What has changed?
> Thanks
> Sven
>
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
--
Alan Boudreault
Mapgears
http://www.mapgears.com
More information about the MapServer-users
mailing list