aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-05-10 13:58:08 -0300
committerSilvio <silvio@devlet.com.br>2010-05-10 13:58:08 -0300
commit3c00fa34ec17cb5865de643aa0490772d7724d56 (patch)
tree38f3b3031b9c01dd5d5fe191a83fec5b275a1c2a /tests
parent424909ae35f5caab06162f15958b72966a981445 (diff)
downloadcinisis-3c00fa34ec17cb5865de643aa0490772d7724d56.tar.gz
cinisis-3c00fa34ec17cb5865de643aa0490772d7724d56.tar.bz2
Adding filter into CSV export
Diffstat (limited to 'tests')
-rw-r--r--tests/csv.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/csv.php b/tests/csv.php
index 1d3c5cb..bea8091 100644
--- a/tests/csv.php
+++ b/tests/csv.php
@@ -5,11 +5,29 @@
/**
* Format a value for CSV output.
+ *
+ * @param $field
+ * Field entry.
+ *
+ * @return
+ * Formatted CSV field.
*/
function csv($field = NULL) {
return '"'. preg_replace('/"/', '""', $field) .'",';
}
+/**
+ * Apply filters into the result.
+ *
+ * @param $field
+ * Field entry.
+ */
+function filter(&$field = NULL) {
+ // Remove brackets from field content.
+ $field = str_replace('<', '', $field);
+ $field = str_replace('>', '', $field);
+}
+
// Import Cinisis Library.
require_once '../index.php';
@@ -44,6 +62,10 @@ if ($isis->db) {
// Format output.
for ($n=1; $n <= $rows; $n++) {
$result = $isis->db->read($n);
+
+ // Filter results.
+ array_walk_recursive($result, 'filter');
+
foreach ($format['fields'] as $field) {
if (is_array($result[$field['name']])) {
echo csv();