This static function will export the content of the database to a xml string. It returns bool(false) on error.
You may limit the output to a certain table or structure file, by setting the arguments $structure and $table. Otherwise the whole database is exported, which is also the default behavior. You may set the argument $structure to NULL, if you just need $table.
Note that both arguments may also be provided as a list of files or tables.
You may set the argument $useForeignKeys to bool(true), if you want references (foreign keys) between tables to be respected. This way tables may be containers for other tables, where there is a relation between both.
To "resolve a foreign key relation" in this case actually means, each foreign key is interpreted as a parent-child relation between two tables. Each row of the child table (the referencing table) is then copied to it's parent row (the row in the referenced table, as identified by the value of the foreign key column in the current row of the child table).
Note, that a table may have multiple parents. This will result in multiple copies of the same row.
Also note, that this function does not detect circular references. However, this is not much of a restriction, as such references are not a legal construct in RDBMSs. Although some RDBMS allow such constructs, it would be "practically" impossible to add any data, without breaking referential integrity, because a row should not contain a checked reference to itself, while it does not exist.
Note: this may result in an error for DBMS that ignore referential integrity, like MyISAM tables in MySQL.
Here is an example to illustrate the behavior of this function. May "foo" and "bar" be tables, with "foo" having a property "bar_id", that is a foreign key, referencing "bar".
The following function call will output the XML representation of both tables:
The result would look something like this:
... XML-head ...
<bar>
<item id="1">
<bar_id>1</bar_id>
<bar_value>0.0</bar_value>
<!-- here come some entries of table foo -->
<bar.foo>
<item id="2">
<foo_id>2</foo_id>
<bar_id>1</bar_id>
<!-- other values -->
</item>
<item id="5">
<foo_id>5</foo_id>
<bar_id>1</bar_id>
<!-- other values -->
</item>
</bar.foo>
</item>
</bar>