From 2ebf1c5ee05b8266cffacec24d4fc09fe31aa458 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Tue, 20 May 2014 16:59:29 -0500 Subject: [PATCH] Move transfer and transfer_array to DatabaseExporter --- include/class.export.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/class.export.php b/include/class.export.php index 51ab41b8b..984c1da07 100644 --- a/include/class.export.php +++ b/include/class.export.php @@ -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')); + } } -- GitLab