Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have been working on creating a web mapping application using ArcServer 10 and the JavaScript API. Recently I was told that queries need to be run using PHP due to prior work by another team. The person that worked on the initial PHP coding has been migrated to my team, but has little experience with geospatial work. In contrast, I have more experince with geospatial work, but I have a limited exposure to working with PHP.

Is it possible to have the PHP interact with ArcSDE and/or PostgreSQL databases through the JavaScript API?

Our end goal is to allow users to query (both through geospatially selecting data and typing queries) via our web mapping application. Users could then click on a "more info" button which retrieves more detailed information about that record in a format that resembles the form it was entered into the database.

Any hints and/or resources would be much appreciated.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

You just need to have the proper connection to the database. IE SQL Sever / Postgres. If the data is already in ArcSDE it is probably easier to create a service and publish it. However, since you mentioned reusing code you just need to call the php file in your page. Look at http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp_start.htm#jshelp/inside_esri_request.html or http://dojotoolkit.org/reference-guide/1.7/dojo/xhrGet.html#dojo-xhrget

The php code needs to return JSON(P)/xml. This is assuming it is available as a web service. David Walsh has a great sample on this method. http://davidwalsh.name/web-service-php-mysql-xml-json

The other way is working within a php page and doing it all with php,html. For this you will find an incredible amount of info on the web most using mysql (Just google for the db you want). Here is a very bare bones mysql example. http://devzone.zend.com/12/php-101-part-8-databases-and-other-animals_part-1/

I like that example because the idea is very simple. Connect, Select, Create, execute, do something with the result.

You can mix and match all of these in your page for example you can build your PHP query dynamically based on the result of an ArcGIS server webservice query. -> Click on parcel and return the parcel ID. Store parcel ID in a variable. Pass Variable into PHP Query. Search records database using that parcel ID number.

Is it possible to have the PHP interact with ArcSDE and/or PostgreSQL databases through the JavaScript API? Yes, If your PHP is set up as a service. (esri.request) If not, use PHP for server side processing.

From your comment -
I think my confusion might spring from where exactly the PHP section fits into the overall system architecture. Basically, I've learned that PostgreSQL tables are referenced within ArcSDE which is then used to create a MXD thus allowing the uploading of data to ArcServer. Where does the PHP component fit in exactly? Does it replace ArcSDE or go on before ArcSDE?

ArcGIS server creates a webservice based on your data. This is what gives you the REST/SOAP endpoint. http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/

Esri does the hardwork and gives you a nice Restful endpoint. All you do is click through a menu. PHP fits in if you need to either connect to another database or simple want to connect to the same database to query and process data. It does not replace ArcSDE in any way. PHP is just a language that you can use. You could also use C#, Java, Ruby, etc.

share|improve this answer
    
Thank you for this! I found your fifth and six paragraphs really helpful. Clicking on a parcel (which contains many points) and returning information about the parcel and/or the points is exactly what I am looking to do. Passing the PHP variable would require the esri.request and a PHP service, correct? Is there a way to optimize this for speed since I've go ~50,000 records? –  jwx Jun 19 '12 at 19:04
    
I personally would create a web service. This is for two reasons. 1. You limit the amount of PHP you need by creating just the web service and not a full application. (For full applications look into Zend, Cake PHP, etc). 2. When the web service is in place you can now connect using various clients. Desktop, Web, Mobile, etc. So the same data available in this site can become available in your Native iOS/Android app in the future. –  theJones Jun 20 '12 at 20:28
    
As for speed I would just look into PHP specific questions. This has probably already been addressed and I am not the expert in that realm. Search for caching results or similar. –  theJones Jun 20 '12 at 20:32
    
Excellent, thank you! –  jwx Jun 20 '12 at 23:43
add comment

For database access, direct methods will be faster. Also don't forget about the PostGIS extension to PostgreSQL, which enables all sorts of spatial goodness.

share|improve this answer
    
I think my confusion might spring from where exactly the PHP section fits into the overall system architecture. Basically, I've learned that PostgreSQL tables are referenced within ArcSDE which is then used to create a MXD thus allowing the uploading of data to ArcServer. Where does the PHP component fit in exactly? Does it replace ArcSDE or go on before ArcSDE? –  jwx Jun 15 '12 at 20:18
    
Sorry, I'm not familiar with ArcSDE, so I can't really say if it is redundant in this case or not. –  lynxlynxlynx Jun 18 '12 at 16:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.