diff options
Diffstat (limited to 'tests/csv.php')
-rw-r--r-- | tests/csv.php | 35 |
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"; + } +} |