
Untitled
By:
ansori87 on
May 30th, 2012 | syntax:
None | size: 1.82 KB | hits: 47 | expires: Never
$result = array();
$zipfile = new zipfile();
for ($i = 0; $i < count($dataSekolah); $i++) {
$result[$i] = $this->exportAll($dataSekolah[$i], $kprop, $kkab, $kkec, $jml_data, $tgl);
$columnName[$i] = $result[$i]->getTable()->getColumnNames();
//header('Content-Type: text/xml');
$xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
$xml .= "<data" . $dataSekolah[$i] . ">";
foreach ($result[$i] as $data) {
$xml .= "<" . $dataSekolah[$i] . ">";
foreach ($columnName[$i] as $column) {
//echo $data[$column] . "<br>";
$xml .= "<" . $column . "> <![CDATA[" . $data[$column] . "]]></" . $column . ">";
}
$xml .= "</" . $dataSekolah[$i] . ">";
}
$xml .= "</data" . $dataSekolah[$i] . ">";
//header("Content-disposition: attachment; filename=$dataSekolah[$i].xml");
$file[$i] = $dataSekolah[$i] . '.xml';
$filename[$i] = 'new'.$dataSekolah[$i] . '.xml';
if (is_file($file[$i]))
unlink($file[$i]);
$fp[$i] = fopen($file[$i], "w+");
fwrite($fp[$i], $xml);
fclose($fp[$i]);
$zipfile->addFile(file_get_contents($file[$i]), $filename[$i]);
//return sfView::NONE;
}
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=test.zip");
echo $zipfile->file();