Hi Andrew,

Typically I solve this kind of problem using the "INCLUDE" statement in a .map 
file:

MAP
STATUS ON
LAYER
NAME 'Test'
TYPE " POLYGON
INCLUDE '../../db_connect.map'
DATA 'the_geom from things using unique gid using SRID=4269'
:

where the db_connect.map would contain things like:

CONNECTIONTYPE POSTGIS
CONNECTION "host=192.168.0.27 dbname=map user=map password=map port=5433"
PROCESSING "CLOSE_CONNECTION=DEFER"

Best Regards,
Brent Fraser
GeoAnalytic Inc

----------------------------------------
From: "Andrew Tegenkamp via MS4W-Users" <[email protected]>
Sent: 3/4/22 8:16 AM
To: [email protected]
Cc: Andrew Tegenkamp <[email protected]>
Subject: [MS4W-Users] Organizing and Using Global Connections in MAP Files

We have MS4W 4.0.5 and are using PostGIS that interacts with a PHP web 
application.

We're using standard Mapfiles and MapScript, and I have the "CONNECTIONTYPE 
postgis" and "CONNECTION "host=..." lines in a bunch of map files and am 
working to clean up and consolidate my code at the moment.

I'd like to find a way to make that a global variable so it's easier to update 
and change. For convenience I'd prefer to store some of the MAP files inside 
the web root but don't want to expose the database connection so I'm keeping it 
outside the web root for now.

My first thought was to set a .htaccess file to process .map files like .php 
and add my own PHP, but of course the mapfile location is a local file c:\ms4w\ 
so it does not process any PHP in a MAP file and tells me "First token must be 
MAP, this doesn't look like a mapfile" which makes sense.

Does anyone have a good strategy for organizing multiple Mapfiles and making a 
more global CONNECTION line that I'm missing?

None of this is a requirement and I can do global find and replace operations, 
but it seemed there may be a better way, so I wanted to reach out and see if 
anyone had a better way than I did!

Thanks,
Andrew
_______________________________________________
MS4W-Users mailing list
[email protected]
https://lists.ms4w.com/mailman/listinfo/ms4w-users

Reply via email to