Friday, April 18, 2008

Outputting SQL results as XML

We are using XML as a format to pass data from PHP to Flex. We have a few different options for how to do this. We have opted to write a function that automatically converts SQL results into XML documents. Another option would have been to convert the results within each separate function, which would have allowed us to sort results into function-specific tree structures. But this would have been a lot of extra work for each function.

I wrote a function called sql2xml() which takes an SQL query as input, runs this query, and returns either the query results or an error message as XML. This is what it looks like (you can click the image to see it at a readable size):

No comments: