Created
October 31, 2013 22:34
-
-
Save dongilbert/7258310 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class SomeClass | |
{ | |
public function resortCsv() | |
{ | |
$db = JFactory::getDbo(); | |
$query = $db->getQuery(true) | |
->select('robot_id, title, address1, city, state, zip, sub_title, description') | |
->from('#__rv_resorts'); | |
$results = $db->setQuery($query)->loadObjectList(); | |
header('Content-Type: text/csv'); | |
header('Content-Disposition: attachment;filename=ResortList.csv'); | |
$output = fopen('php://output', 'w'); | |
$headers = array('RobotID', 'Title', 'Address', 'City', 'State', 'Zip', 'Sub Title', 'Description'); | |
fputcsv($output, $headers); | |
foreach ($results as $row) | |
{ | |
$entry = array( | |
$row->robot_id, | |
$row->title, | |
$row->address1, | |
$row->city, | |
$row->state, | |
$row->zip, | |
$row->sub_title, | |
$row->description | |
); | |
fputcsv($output, $entry); | |
} | |
fclose($output); | |
exit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment