aboutsummaryrefslogtreecommitdiff
path: root/tests/csv.php
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-05-05 12:31:54 -0300
committerSilvio <silvio@devlet.com.br>2010-05-05 12:31:54 -0300
commitac1c73e16ddd53b40af71c6783cb542bcebc6944 (patch)
tree6ed27ac9d01c29ff6ae75b57c743b3f8341ef5cd /tests/csv.php
parent09a601d58cfaf66dc4ea5cfe998aa676cad5d9e7 (diff)
downloadcinisis-ac1c73e16ddd53b40af71c6783cb542bcebc6944.tar.gz
cinisis-ac1c73e16ddd53b40af71c6783cb542bcebc6944.tar.bz2
CSV export enhancements
Diffstat (limited to 'tests/csv.php')
-rw-r--r--tests/csv.php22
1 files changed, 17 insertions, 5 deletions
diff --git a/tests/csv.php b/tests/csv.php
index 2618cd0..6c06322 100644
--- a/tests/csv.php
+++ b/tests/csv.php
@@ -11,24 +11,36 @@ $isis = new CinisisDb();
// Test connection.
if ($isis->db) {
- // Prepare output
+ // Get format and number of rows.
+ $rows = $isis->db->rows();
+ $format = $isis->db->format;
+
+ // 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;
-
+ // Format fields.
foreach ($format['fields'] as $field) {
echo $field['name'] .',';
+ if (is_array($field['subfields'])) {
+ foreach ($field['subfields'] as $key => $value) {
+ echo $field['name'] .': '. $value.',';
+ }
+ }
}
+ // Format output.
for ($n=1; $n <= $rows; $n++) {
$result = $isis->db->read($n);
- // Format output.
foreach ($format['fields'] as $field) {
echo $result[$field['name']] .',';
+ if (is_array($field['subfields'])) {
+ foreach ($field['subfields'] as $key => $value) {
+ echo $result[$field['name']][$value] .',';
+ }
+ }
}
echo "\n";
}