Service Data Objects

Service Data Objects by Graham Charters

Service Data Objects (SDOs) enable PHP applications to work with data from different sources (like a database query, an XML file, and a spreadsheet) using a single interface.

– Data Access Services
. Now we have a data structure we need some way to get data in and out of it..
. SDO applications use DAS to read/write to/from differente sources of data such as databases or XML files
. A DAS converts between a data source format and SDO. For example: SDO Relational Database

(cont…)

– Relational DAS introduction
Steps in using the relational DAS
1. Describe the database schema and parent-child relationships
2. Retrieve or create a data object
3. Update or set the data object properties
4. Apply the updates back to the database

– Describing the database schema
. Describe the database schema (tools help would be nice)
. table name = data object type
. column name = data object property name
. foreign keys (none specified in this example) = become data object references (hidden if containment)

– Basically you load the data into an object, you make the changes to the object and then you commit the changes.
– RDAs creates SQL statements based on the changes
. Statements are qualified with original values (captured by SDO in the $root data objects’ change summary) to detect collisions
. Any collisions result in all changes being rolled back

Steps in using the XML DAS
1. Describe the XML schema
2. Load a XML document or create a data object
3. Update or set the data object properties
4. Write out the data object as an XML document

– Describe the XML schema – some of the rules:
. Complex types = data object types
. Element/attribute name = data object property name

– XML DAS scenarios
. SDO and XML DAS are tailored to scenarios where one or more of the following are true:
. there exists an XML schema governing the document structure
. creation or significant manupulation of a document is required
. application uses both XML and relational data

Documentation:
http://livedocs.phpdoc.info
http://docs.php.net