DB_DataObject & XML Renderer
| From: | Chris Boget | Date: | Sun, 15 Oct 2006 23:47:55 +0000 |
| Subject: | DB_DataObject & XML Renderer | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-25452@lists.php.net to get a copy of this message | ||
I don't think this is possible. I've tried but couldn't get it to work. I'm hoping that I can get confirmation that I'm chasing my tail or if, in fact, what I'm trying to do will work.
I have 2 tables, one having a 1-M relationship with the other. If I run a query like this:
SELECT table1.name, table2.orderItem, table2.orderQuantity, table2.orderAmount
FROM table1
INNER JOIN table2 ON table2.table1Id = table1.id
and run it through the XML Renderer I get something that looks like this:
<root>
<row>
<name>bob</name>
<orderItem>Item 1</orderItem>
<orderQuantity>5</orderQuantity>
<orderAmount>100</orderAmount>
</row>
<row>
<name>bob</name>
<orderItem>Item 2</orderItem>
<orderQuantity>5</orderQuantity>
<orderAmount>100</orderAmount>
</row>
<row>
<name>bob</name>
<orderItem>Item 3</orderItem>
<orderQuantity>5</orderQuantity>
<orderAmount>100</orderAmount>
</row>
</root>
If there are 3 rows in table2. What I'm hoping I can get out of it is something that looks like this:
<root>
<row>
<name>bob</name>
<linkedrows>
<row>
<orderItem>Item 1</orderItem>
<orderQuantity>5</orderQuantity>
<orderAmount>100</orderAmount>
</row>
<row>
<orderItem>Item 2</orderItem>
<orderQuantity>5</orderQuantity>
<orderAmount>100</orderAmount>
</row>
<row>
<orderItem>Item 3</orderItem>
<orderQuantity>5</orderQuantity>
<orderAmount>100</orderAmount>
</row>
</linkedrows>
</root>
Is that possible? Or am I going to have to output the XML on my own?
thnx,
Chris