diff options
author | Silvio <silvio@devlet.com.br> | 2010-05-05 11:55:41 -0300 |
---|---|---|
committer | Silvio <silvio@devlet.com.br> | 2010-05-05 11:55:41 -0300 |
commit | 09a601d58cfaf66dc4ea5cfe998aa676cad5d9e7 (patch) | |
tree | 005d06592d8bf97d336c74b8f6c87a0db190995e /tests | |
parent | db05f3f13306bf14681c0399eaa9433280071d64 (diff) | |
download | cinisis-09a601d58cfaf66dc4ea5cfe998aa676cad5d9e7.tar.gz cinisis-09a601d58cfaf66dc4ea5cfe998aa676cad5d9e7.tar.bz2 |
Initial test code for csv export
Diffstat (limited to 'tests')
-rw-r--r-- | tests/csv.php | 35 | ||||
-rw-r--r-- | tests/index.php | 2 | ||||
-rw-r--r-- | tests/read.php | 2 |
3 files changed, 37 insertions, 2 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"; + } +} diff --git a/tests/index.php b/tests/index.php index 7297b40..5a14f22 100644 --- a/tests/index.php +++ b/tests/index.php @@ -13,7 +13,7 @@ <?php -// Import Malete Library. +// Import Cinisis Library. require_once '../index.php'; // Get a db instance. diff --git a/tests/read.php b/tests/read.php index eae1488..146234c 100644 --- a/tests/read.php +++ b/tests/read.php @@ -15,7 +15,7 @@ <?php -// Import Malete Library. +// Import Cinisis Library. require_once '../index.php'; $configs = array( |