开发者

How can i use php to export a mysql table

开发者 https://www.devze.com 2023-04-07 11:07 出处:网络
I am trying to export just the rows of a mysql table without the table information to an xml file. I read that the mysqldump command will get the job done but I cant manage to get the correct syntax.

I am trying to export just the rows of a mysql table without the table information to an xml file. I read that the mysqldump command will get the job done but I cant manage to get the correct syntax. Can someone post an example code for mysqldump com开发者_StackOverflow中文版mand? Thank you.

$command="mysqldump --xml ";


Try the script on this page: http://www.chriswashington.net/tutorials/export-mysql-database-table-data-to-xml-file


By any chance you are not trying to run that command inside mysql_query are you ? It wont work that way. mysqldump is a command line utility.

To run it from php you would need to use the system() function, documentation - http://php.net/manual/en/function.system.php

If you are on a shared host with PHP in safe mode, or the system function is explicitly disabled in php.ini, then you will not be able to do this.

In that case you would need to read the data from your table using a SELECT query and iterating on all rows and potting it into an XML file, using XMLWriter or DOMDocument

0

精彩评论

暂无评论...
验证码 换一张
取 消