[mapserver-users] php mapscript
Alan Boudreault
aboudreault at mapgears.com
Thu Mar 25 08:08:05 PDT 2010
Sven,
I don't know really what's happen in your case..... but getShape/getFeature
seem to return NULL or FALSE. It's not an object, so there is no ->values
array and ->free method available neither.
Alan
On March 25, 2010 10:52:12 am Sven Schroeter wrote:
> Alan,
> thanks for the reply, I tried it with getFeature(), but there comes the
> same error.
> nextShape() works only after msWhichShapes and here I need a rectobj.
> But I want to use the script for queryByShape and queryByAttributes too.
> Why there comes no array in $attr = $shpobj->values; ?
> Any idea?
> Sven
>
> ----- Original Message -----
> From: "Alan Boudreault" <aboudreault at mapgears.com>
> To: <mapserver-users at lists.osgeo.org>
> Cc: "Sven Schroeter" <schroeter at netgis.de>
> Sent: Thursday, March 25, 2010 2:32 PM
> Subject: Re: [mapserver-users] php mapscript
>
> > 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
>
> _______________________________________________
> 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