aboutsummaryrefslogtreecommitdiff
path: root/tests/csv.php
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-05-05 11:55:41 -0300
committerSilvio <silvio@devlet.com.br>2010-05-05 11:55:41 -0300
commit09a601d58cfaf66dc4ea5cfe998aa676cad5d9e7 (patch)
tree005d06592d8bf97d336c74b8f6c87a0db190995e /tests/csv.php
parentdb05f3f13306bf14681c0399eaa9433280071d64 (diff)
downloadcinisis-09a601d58cfaf66dc4ea5cfe998aa676cad5d9e7.tar.gz
cinisis-09a601d58cfaf66dc4ea5cfe998aa676cad5d9e7.tar.bz2
Initial test code for csv export
Diffstat (limited to 'tests/csv.php')
-rw-r--r--tests/csv.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/csv.php b/tests/csv.php
new file mode 100644
index 0000000..2618cd0
--- /dev/null
+++ b/tests/csv.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Cinisis - Isis db reading tool.
+ */
+
+// Import Cinisis Library.
+require_once '../index.php';
+
+// Get a db instance.
+$isis = new CinisisDb();
+
+// Test connection.
+if ($isis->db) {
+ // Prepare output
+ header("Content-type: application/text/x-csv");
+ header("Content-Disposition: attachment; filename=export.csv");
+ header("Pragma: no-cache");
+ header("Expires: 0");
+
+ $rows = $isis->db->rows();
+ $format = $isis->db->format;
+
+ foreach ($format['fields'] as $field) {
+ echo $field['name'] .',';
+ }
+
+ for ($n=1; $n <= $rows; $n++) {
+ $result = $isis->db->read($n);
+ // Format output.
+ foreach ($format['fields'] as $field) {
+ echo $result[$field['name']] .',';
+ }
+ echo "\n";
+ }
+}