Re: XML/MySQL
| From: | Burhan Khalid | Date: | Mon, 27 Oct 2003 04:40:06 +0000 |
| Subject: | Re: XML/MySQL | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-167673@lists.php.net to get a copy of this message | ||
Ian Williams wrote:
I want to write a function that will take any SQL query as a parameter, and generate XML that represents the recordset.If you are lucky enough to be using mysql ver 4.x+ -- it has this functionality built-in, using the --xml command line option. Sample run : $ mysql -u username -ppassword --xml mysql> create table test (name text, pass text); Query OK, 0 rows affected (0.00 sec) mysql> insert into test (name,pass) values ('foo','secret'); Query OK, 1 row affected (0.00 sec) mysql> select * from test; <?xml version="1.0"?> <resultset statement="select * from test"> <row>
<name>foo</name>
<pass>secret</pass>
</row>
</resultset>
1 row in set (0.00 sec)
mysql>
If your mysql version is < 4.x -- then you have to resort of one of the many mysql-to-xml classes available (check phpclasses.org and PEAR).
--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com