From 8b085bb0183d24c723ffbda9723b26ab0a1b4a16 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 12 May 2010 12:08:43 -0300 Subject: Filtering empty results on BiblioIsis and on CSV export --- classes/BiblioIsisDb.php | 14 ++++++++------ tests/csv.php | 32 +++++++++++++++++--------------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/classes/BiblioIsisDb.php b/classes/BiblioIsisDb.php index 81db3e7..e902a93 100644 --- a/classes/BiblioIsisDb.php +++ b/classes/BiblioIsisDb.php @@ -87,14 +87,16 @@ class BiblioIsisDb implements IsisDb { // Database query. $results = $this->backend('to_hash', $id); - // Tag results. - $data = $this->tag($results); + if ($results) { + // Tag results. + $data = $this->tag($results); - // Charset conversion. - array_walk_recursive($data, array(__CLASS__, 'charset')); + // Charset conversion. + array_walk_recursive($data, array(__CLASS__, 'charset')); - // Return the result. - return $data; + // Return the result. + return $data; + } } /** diff --git a/tests/csv.php b/tests/csv.php index bea8091..52c5fd5 100644 --- a/tests/csv.php +++ b/tests/csv.php @@ -63,24 +63,26 @@ if ($isis->db) { for ($n=1; $n <= $rows; $n++) { $result = $isis->db->read($n); - // Filter results. - array_walk_recursive($result, 'filter'); + if ($result) { + // Filter results. + array_walk_recursive($result, 'filter'); - foreach ($format['fields'] as $field) { - if (is_array($result[$field['name']])) { - echo csv(); - } - else { - echo csv($result[$field['name']]); - } - if (is_array($field['subfields'])) { - foreach ($field['subfields'] as $key => $value) { - echo csv($result[$field['name']][$value]); + foreach ($format['fields'] as $field) { + if (is_array($result[$field['name']])) { + echo csv(); + } + else { + echo csv($result[$field['name']]); + } + if (is_array($field['subfields'])) { + foreach ($field['subfields'] as $key => $value) { + echo csv($result[$field['name']][$value]); + } } } - } - // New roll. - echo "\n"; + // New roll. + echo "\n"; + } } } -- cgit v1.2.3