|
1 | | -######### |
2 | | -Utilities |
3 | | -######### |
| 1 | +###################### |
| 2 | +Database Utility Class |
| 3 | +###################### |
4 | 4 |
|
5 | 5 | The Database Utility Class contains methods that help you manage your database. |
6 | 6 |
|
7 | 7 | .. contents:: |
8 | 8 | :local: |
9 | 9 | :depth: 2 |
10 | 10 |
|
11 | | -******************* |
12 | | -Get XML from Result |
13 | | -******************* |
| 11 | +****************************** |
| 12 | +Initializing the Utility Class |
| 13 | +****************************** |
14 | 14 |
|
15 | | -getXMLFromResult() |
16 | | -================== |
| 15 | +Load the Utility Class as follows: |
17 | 16 |
|
18 | | -This method returns the xml result from database result. You can do like this: |
| 17 | +.. literalinclude:: utilities/002.php |
| 18 | + :lines: 2- |
| 19 | + |
| 20 | +You can also pass another database group to the DB Utility loader, in case |
| 21 | +the database you want to manage isn't the default one: |
| 22 | + |
| 23 | +.. literalinclude:: utilities/003.php |
| 24 | + :lines: 2- |
| 25 | + |
| 26 | +In the above example, we're passing a database group name as the first |
| 27 | +parameter. |
| 28 | + |
| 29 | +**************************** |
| 30 | +Using the Database Utilities |
| 31 | +**************************** |
| 32 | + |
| 33 | +Export a Query Result as an XML Document |
| 34 | +======================================== |
| 35 | + |
| 36 | +Permits you to generate an XML file from a query result. The first |
| 37 | +parameter expects a query result object, the second may contain an |
| 38 | +optional array of config parameters. Example: |
19 | 39 |
|
20 | 40 | .. literalinclude:: utilities/001.php |
21 | 41 |
|
22 | | -and it will get the following xml result:: |
| 42 | +and it will get the following xml result when the ``mytable`` has columns ``id`` and ``name``:: |
23 | 43 |
|
24 | 44 | <root> |
25 | 45 | <element> |
26 | 46 | <id>1</id> |
27 | 47 | <name>bar</name> |
28 | 48 | </element> |
29 | 49 | </root> |
| 50 | + |
| 51 | +.. important:: This method will NOT write the XML file for you. It |
| 52 | + simply creates the XML layout. If you need to write the file |
| 53 | + use the :php:func:`write_file()` helper. |
0 commit comments