Skip to content

Commit d0f3541

Browse files
author
Radovan Janjic
committed
Update README.md
1 parent 431bfb8 commit d0f3541

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ This class implements a generic MySQL database access wrapper.
2828
* [Import CSV to Table](#import-csv-to-table)
2929
* [Import and update CSV to Table](#import-and-update-csv-to-table)
3030
* [Create table from CSV file](#create-table-from-csv-file)
31+
* [Operations with XML files](#operations-with-xml-files)
32+
* [Export query to XML](#export-query-to-xml)
3133
* [Do str_replace in given database, table or defined columns in table](#string-search-and-replace-in-all-or-defined-table-columns)
3234
* [Search string & replace string](#string-search-and-replace-in-all-or-defined-table-columns)
3335
* [Search array & replace string](#string-search-and-replace-in-all-or-defined-table-columns)
@@ -739,6 +741,33 @@ $db->createTableFromCSV('test_files/countrylist1.csv', 'csv_to_table_test_no_col
739741
$db->close();
740742
```
741743

744+
### Operations with XML files
745+
746+
#### Export query to XML
747+
```php
748+
$db = MySQL_wrapper::getInstance(MySQL_HOST, MySQL_USER, MySQL_PASS, MySQL_DB);
749+
750+
// Connect
751+
$db->connect();
752+
753+
// Save result as file
754+
$db->query2XML('select * from `table` limit 10', 'items', 'item', 'test_files/test-query2xml.csv');
755+
756+
// Return result as XML
757+
$xml = $db->query2CSV('select * from `table` limit 10', 'items', 'item');
758+
759+
/** Export query to XML file or return as XML string
760+
* @param string $query - mysql query
761+
* @param string $rootElementName - root element name
762+
* @param string $childElementName - child element name
763+
* @return string - XML
764+
*/
765+
// function query2XML($query, $rootElementName, $childElementName, $file = NULL);
766+
767+
// Close connection
768+
$db->close();
769+
```
770+
742771
### Transactions
743772
```php
744773
$db = MySQL_wrapper::getInstance(MySQL_HOST, MySQL_USER, MySQL_PASS, MySQL_DB);

0 commit comments

Comments
 (0)