Skip to content
Snippets Groups Projects
Commit 2ebf1c5e authored by Jared Hancock's avatar Jared Hancock
Browse files

Move transfer and transfer_array to DatabaseExporter

parent 906a6b18
No related branches found
No related tags found
No related merge requests found
......@@ -375,4 +375,32 @@ class DatabaseExporter {
$this->write_block(array('end-table'));
}
}
function transfer($destination, $query, $callback=false, $options=array()) {
$header_out = false;
$res = db_query($query, true, false);
$i = 0;
while ($row = db_fetch_array($res)) {
if (is_callable($callback))
$callback($row);
if (!$header_out) {
$fields = array_keys($row);
$this->write_block(
array('table', $destination, $fields, $options));
$header_out = true;
}
$this->write_block(array_values($row));
}
$this->write_block(array('end-table'));
}
function transfer_array($destination, $array, $keys, $options=array()) {
$this->write_block(
array('table', $destination, $keys, $options));
foreach ($array as $row) {
$this->write_block(array_values($row));
}
$this->write_block(array('end-table'));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment