Can I expose MySQL data using PHP and OData? - php

As I understand it, OData is just a standardized way to expose relational data RESTfully. If I've got a PHP application, it should be able to process those RESTful requests and manipulate a MySQL database based on the request data and then return an ATOM feed. First, are the preceeding statements correct? Second, does a PHP library to do this already exist or would I have to create my own?
If I have completely misunderstood these technologies and my question doesn't make sense, please feel free to let me know.

OData is a way of exposing all sorts of structured data over an HTTP interface. The underlying repository for data may be relational or not. For example, when using WCF Data Services on top of SQL Server it's certainly a relational data set, but the OData endpoints in SharePoint Server 2010 or on Windows Azure Table Storage run on top of other data models. The high order bit is to make all data available in a web-friendly way.
As for your specific question about MySQL/PHP, there is an OData client for PHP but to my knowledge there isn't a server implementation available. I know there is a MySQL provider for ADO.NET, maybe if it has Entity Framework support you can use WCF Data Services, but that means you'd be running on .NET and not on PHP, don't know if it's acceptable for your situation.

MySQL/PHP OData Server - http://sourceforge.net/projects/mysqlodata/

Here is a library to do what you want:
https://github.com/MSOpenTech/odataphpprod/

The library you needed came out only in September 2011. Here is an MSDN article.

Related

Connecting to a MS SQL 2012 using jquery?

I've built a web app using Sharepoint 2010 and was able to connect to a Sahrepoint list using REST API (ajax). THis method allowed to use a Sharepoint list as a database.
Now I am in the process of creating a web server with MSSQL. I havent dealt with MSSQL a whole lot to be honest. I know that the ideal way to access the database is via PHP but its not an option at this moment. So i'm trying to see if I can simply use jquery/javascript to get, update, create and delete records using AJAX.
Im having a hard time finding any info on this but would anyone know if MSSQL allows HTTP access liek Sharepoint's REST API?
I would imagine there might be a way to activate this function in MSSQL somehow but again, not finging a whole lot of noob guides or noob info on this. I would appreciate any input.
No, MSSQL does not natively host any RESTful APIs. You will need to use some kind of back end/server side code to actually make the database connection and run queries/return results.
You could use PHP (which is probably not the "ideal" for working with an MS product, but would certainly work), but you could also use a host of other server side languages - Perl, Python, Java, C#, C, C++, etc. and just expose JSON/RESTful methods for jQuery to interface with.
The "ideal" currently would be to look into oData services. Most likely you'd write an oData service hosted as a WCF service or ASP.NET site in C#.
See also:
http://www.hanselman.com/blog/CreatingAnODataAPIForStackOverflowIncludingXMLAndJSONIn30Minutes.aspx
how to query SQL Server via REST to get XML.

Get data from SAP CRM to PHP

I'm trying to automate getting(posting) data from SAP CRM using my server (cURL/PHP+MSSQL), but have some problems with it.
There is no access allowed except this web interface.
I tried to use cURL, using POST fields from FireBug, but it returned only logon error.
Questions:
Is there any solution or API?
Has anybody tried it?
Thanks.
Yes, there are APIs, though you'll have to be more specific about exactly what data you want in order to say if a particular API to serve your needs exists. SOAP web services are an option that may provide the information you need and there are PHP SOAP libraries. You'll need to talk to your SAP team to get access to the system, and you will probably want to be much more specific about the exact data you need access to.
If your company has Gateway, you can also define OData APIs. And it is, of course, possible to define your own RESTful (or other) HTTP APIs using SAP's HTTP stack. Again, you'll need to talk to your SAP team about this.

How do I locally simulate accessing a Dynamics CRM database for use with SOAP?

I am currently starting on a project for school where we are to make a prototype for an application that uses PHP and SOAP to access a Dynamics CRM server.
So far I've gotten my apache server up and running and a project set up in Netbeans, simple .php files work just fine...
Now I'd need a similar database as is used in a MS Dynamics CRM system that I can run locally (so no network connection or configuration is required). Connection to the actual database (of the company we make the prototype for) is impossible.
An SQL server would be the easiest option I know of (according to a post here MySQL is incompatible with the dynamics database so that's not an option) since we have used this in class already, but is this a comparable database to the one used in Dynamics CRM?
This assignment is slightly out of my league since I have had no experience with PHP or SOAP coding, but then again we only need to simulate a couple of simple insert/update/delete/... statements - only problem being I have no idea how I should simulate their database.
Thanks in advance for you help, feel free to ask any extra questions if you need more information
Just having a database isn't going to be enough here. Dynamics CRM is the application which has the SOAP web service endpoint and then performs any actions on the database.
You cannot just run SOAP calls directly against the database and you should not be directly editing the CRM database - its not supported by Microsoft.
What you really need is a full development environment - CRM, SQL, AD the whole setup.
So traditionally you might go for a local server with CRM On-Premise, SQL and all their prerequisites installed, not a cheap option and it sounds like it might be beyond your current resources.
So my suggestion would be to go for CRM Online - basically Microsoft host everything and you access CRM via the web. CRM Online is basically the same as CRM On-Premise, there are some key differences but you will be able to perform all your SOAP calls against a real working CRM.
Even better CRM Online has a 30-Day free trial, after that its a $44 a month per user, but as I understand you can just keep creating more free trials.
Also you then need to get your clients customisations installed on the environment. You can export those from CRM and import them into your development environment. You can do this without taking an live data - which is probably why the client doesn't want to give you their database. The reason this is important is so you have the correct data model which is very important for the SOAP web service calls.
In regards to the PHP SOAP bits you might want to have a look at: PHP MSCRM, I haven't used it myself but it looks useful.
As a side, you may want to look at the OData endpoint of MSCRM you may find it more straightforward to use from PHP.

What is the best way to connect an android application and a php server using sockets?

What is the best way to connect an android application and a php server using sockets? I am trying to implement a chat system between multiple clients, but I know that PHP does not allow multithreads.
Sorry for not giving enough information about what I intend to do. I basically want to create an app simmilar to google latitude, and I also want to implement a chat system between the users. I have aldready decided that I am going to use a MySQl DB and therfore a PHP server so the client communicates with the DB using JSON for data exchange. I am quite new to this and I don't know how the architecture Client-Server-Client communication should look like. I found out that the easiest way to do this is using HTTP requests, but I don't know how I should implement this.
I think you can use jabber protocol, install any xmpp server and you can connect to that from android, this is standard for chat applications
use xml-rpc base php webservices for chat server. your chat client will contact to chat server throught web services.
*I was going to make this a comment but I ran out of space, plus it does have some answer-y qualities to it.
This question does not contain nearly enough information for anyone to usefully help you. How do you think it should be done? You can't ask people to critique an idea when you haven't told them what your idea is.
PHP is the wrong language for this, because (as you rightly point out) it can't be multi-threaded - amongst a multitude of other reasons. I personally would recommend Node.js (or possibly Java), but that's just my preference.
If you still insist on using PHP, take a look at this. It might give you a point in the right direction for a non-blocking multi-IO setup such as this - but you're letting yourself into a whole world of unnecessary complication by doing this in PHP.

Best service/connection combo for Flex/Server Implementation

I'm starting a Flex app on a pretty big reporting engine and want to know how best to connect to a Postgres Database. I'd like to create a REST API architecture so I can use the service for more than just the Flex app(mobile possibly).
These are my options I've found:
Datatype: either XML, JSON or AMF
Flex Service: HTTPService or WebService
Server(using PHP): ZendAMF, custom json_encode implementation, Zend_Rest_Server
I've got my views all mapped out, and the api functions designed. Basically what I need is advice on which Flex / back-end service combo to provide.
Thanks for the advice!
Best service/connection combo for Flex/Server Implementation
There is no best way, but actually depends upon your project and how would you like to proceed. There are three ways.
Remoting
HTTP Service
Web Service
Since you would like to re use those services in other applications too, i would suggest you to go with Web Service. You can create your Web Service using any Server siding language which you prefer and communicate it with your Flex Application.
Regarding AMF
Its one of the ways how you can interact your Flex App with Server siding language. AMFPHP or ZendAMF does a good job and its so easy to communicate.
I would suggest you to concentrate more on Flex Architecture rather than looking into how your Flex is gonna communicate with Backend.
Check out for Modules based Architecture.
Check for which framework you are going to develop your Flex App. [ Mate, Cainogram, Swiz or someother] When you have decided with your frontend Architecture on how the flow should happen, you can then decide on how to communicate and which is the best possible approach for your project keeping the future things in your mind.
Since your Application is going to be reports oriented, go for Web Service.
[I] want to know how best to connect to a
Postgres Database.
Best is very subjective. You probably don't want to connect to the Postgres database directly from Flex. Flex is not designed for such things. I recommend using an application server as middleware. ColdFusion, .NET, PHP, Java, and just about any other 'current' application server can be used as that middleware. I would recommend using whatever you (or your team) is familiar with.
For Flex, I strongly recommend you using an AMF implementation. AMF is a binary format and will give you smaller data transfer packets, plus server side object to client side object conversion. It'll save you some time writing XML parsing routines, which can be annoying at times.
With ColdFusion, it is pretty easy to create a server side service (CFC) that can be used for AMF, SOAP Web Services, and REST services all at the same time. You just specify 'access="remote"' on the function definition. I would expect other server side languages have similar functionality, but never investigated the web service related features of other languages.

Categories