/ Published in: PHP
URL: http://reactor.cl
Expand |
Embed | Plain Text
<?php /* Usage: /* /* $report = new Reports_Core; (In Kohana just new Reports;) /* print $report->csv($result_set_or_array, 'a title', ';'); /* /*--------------------------------------------------------------*/ class Reports_Core { function csv($lines = FALSE, $title = '', $delimiter = ';') { $output = ''; if($title) $output .= $title."\n"; if($lines) { foreach($lines as $line) { $report_line[] = $line."\n"; } return $output; } else { } } } ?>
Comments
Subscribe to comments
You need to login to post a comment.

Real world usage:
php
...
header('Content-type: text/csv'); header('Content-disposition: attachment; filename="report_'.$this->person->name.'.csv"');
$historic = $this->reports->gethistoric($person->id, Utils::getdate()); // Get historic resultset view from DB where date is provided by helper Utils method get_date();
print Reports::csv($historic);
Actually you should replace if($title) echo $title."\n"; for something like if($title) $output = $title."\n"; and instead of return implode... $output .= implode... and then return all together.