Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I expose MySQL data using PHP and OData?

Tags:

php

mysql

odata

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.

like image 497
John W Avatar asked Jun 06 '10 17:06

John W


People also ask

How will you PHP to access data from MySQL?

Data can be fetched from MySQL tables by executing SQL SELECT statement through PHP function mysql_query. You have several options to fetch data from MySQL. The most frequently used option is to use function mysql_fetch_array(). This function returns row as an associative array, a numeric array, or both.

Can we use PHP and MySQL together?

With PHP, you can connect to and manipulate databases. MySQL is the most popular database system used with PHP.

How use PHP with MySQL database with example?

php $servername = "localhost"; $username = "username"; $password = "password"; try { $conn = new PDO("mysql:host=$servername;dbname=newDB", $username, $password); // setting the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "CREATE DATABASE newDB"; // using exec() ...


1 Answers

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.

like image 57
Pablo Castro Avatar answered Sep 19 '22 09:09

Pablo Castro