diff options
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( |