[mapserver-users] Mapserver query using database connection

Pavel Iacovlev iacovlev.pavel at gmail.com
Fri Dec 10 03:07:34 PST 2010


In mapserver you can specify the desired SQL query with variables in the
DATA section and create a template for it (example is for Postgis but works
for MSSQL in a similar way)
CONNECTIONTYPE POSTGIS
CONNECTION "dbname=yourdatabasename user=yourdbusername"
DATA "the_geom from (select g.gid, g.the_geom, a.attr1, a.attr2 from
geotable g join attrtable a on g.gid = a.aid) as subquery unique gid using
srid=4326"

You can avoid mapserver template's for querying if you
1) Want to do it from PHP anyway
2) You don't specifically need it in WMFS/WFS GetFeatureInfo format
For example create info.php that queries your databse and returns the
geometry as WKT and needed attributes, convert them to JSON/XML and send
back to web-browser where it can be easily read and displayed by OpenLayers.

On Fri, Dec 10, 2010 at 12:35 PM, Marcus <the_incredibal at gmx.de> wrote:

>  Hello,
>
> I am a cartography student from Germany und I am working on my diploma
> thesis at the moment. My task is to plan and create a webservice application
> for a transportation company and I decided to use the UMN Mapserver for the
> implementation. The users should have the ability to query the objects, too.
> As you probably know the query function of Mapserver allows to query the
> attribute table or to join another table-file, but now there’s my question:
> Is it possible to create a query which directly connects to an existing
> database via PHP and show the results in a query template? I have doubts
> that this could work, cause the query function uses mapserver variables
> which are converted into the strings or numbers like they are in the
> attribute table by the Mapserver program and in my opinion a database won’t
> understand these variables. But may be you’ve heard of a possibility and I
> would be glad if anyone could help me. Please keep in my mind that I have to
> use a Microsoft SQL Server 2008 database and sqlserv as the “driver”.
>
> Thank you and best regards from Germany.
>
> Marcus
>
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>


-- 
http://iap.md, The future is open
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20101210/304de8a5/attachment.htm>


More information about the MapServer-users mailing list