[mapserver-users] Cannot pass variable with php MapScript to the Mapfile

Iacovlev Pavel iacovlev.pavel at gmail.com
Mon Jul 7 01:53:15 PDT 2008


Don't know if you actualy can pass %var% like this in phpmapscript, 

Use mapscript to set stuff.

$layer = $map->getLayerByName('someLayer');
$layer->set('connectiontype', MS_POSTGIS);
$layer->setProcessing('close_connection=defer');
$layer->set('connection', $this->db->connString);
$layer->set('data', 'YOUR SQL HERE');

On Sunday 06 July 2008 22:26:17 John Beck wrote:
> I have an application in which I pass a variable %table%  thru the url to
> the Mapserver mapfile and it works great.
>
> My example
>
> LAYER
> CONNECTION "<OGRVRTDataSource>
> <OGRVRTLayer name='data'>
> <SrcDataSource>MYSQL:xxxx,user=xxxx,password=xxxxx,port=3306,tables=%table%
></SrcDataSource> <SrcSQL>SELECT * FROM %table%</SrcSQL>
> <GeometryType>wkbPoint</GeometryType>
> <LayerSRS>WGS84</LayerSRS>
> <GeometryField encoding='PointFromColumns' x='Long' y='Lat'/>
> </OGRVRTLayer>
> </OGRVRTDataSource>"
> CONNECTIONTYPE OGR
>
> But now I am trying to use mapscript to print the map and when I call
>
> $image = $mapfile->draw()
>
> I get errors wanting to know the value of %table%
>
> How do I implement this function when using PHP/Mapscript.  When creating a
> new MapObj and drawing the map, url-parameters or cookies appear not to be
> passed to the mapserver.





More information about the MapServer-users mailing list