Now that we have seen how to get and set the properties on a data object and how to connect them, we need to explain how to create data objects.
SDOs are created by calling a data factory object. Before the data factory will create anything, it needs to have defined to it the model -- that is, the set of type names and the properties each type can have. It is this model that constrains the properties types can take, so that, for example, you cannot normally add a property to a data object if that property is not in the model, and you cannot assign a data object of one type to a property that has been specified to take a property of a different type.
Most PHP programmers will know that much of the function they use resides in PHP extensions, which usually either come packaged with their PHP distribution or can be downloaded from the PECL site. One such extension supports Service Data Objects (SDO) for PHP, which in February moved from a beta-level 0.9.0 release to a stable 1.0. Written by some of the original developers of the SDO extension, this article is aimed at the PHP programmer who wants to understand what SDO for PHP is, how it can be used, and how it can streamline working with XML.
Agenda
-SDO Concepts
-Data Access Services
--Relational Data Access Service
--XML Data Access Service
-Other capabilities
-Future enhancements
-Useful links
At last month's Zend Conference I was fortunate enough to attend Christian Wenz's tutorial on XML and Web services. This covered the use of technologies such as DOM and SimpleXML for working with XML data. As the title of this blog entry suggests, SDO provide a simple way to construct or extend XML documents.
The example below shows an XML schema used by an application which records information regarding quotations people have made (Thanks go to Christian Wenz for the scenario which is from his book entitled, "PHP Phrasebook", SAMS Publishing.). An XML document following this schema will contain a quotes element containing a number of quote elements, each of which consists of a phrase and an author element and a year attribute.
The slides give an overview of the main concepts behind SDOs, followed by a few scenarios showing how to use them to work with relational and XML data. As I mentioned in a previous blog, the presentation could have done with a few more scenarios to address SDO's strengths and the questions which arose, but unfortunately time was short. I therefore intend to use this blog to cover these over time.
I presented an introduction to SDO for PHP at the Zend/PHP Conference and Expo a couple of weeks ago. The session was very well attended and there were some good questions at the end. Overall the presentation went well, but I could have done with more scenarios to address SDO's real strengths and the questions which arose. To continue the discussion and help clarify a few things, I thought I'd blog a little about SDO. So here goes...
So, I decided that it was high time I took a look at SDO. The Service Data Object extension from IBM.
To say the least, SDO looked interesting, with the ability to access data from a Database (via PDO) and data in XML files (and potentionally any other format) from a single API is appealing.








