Example #1
0
$I = -1;
foreach ($Data as $Item) {
    $I++;
    $II = -1;
    foreach ($Item as $K => $V) {
        $II++;
        // Manipulate value if needed
        if (isset($ColumnCommands[$K]) && isset($ColumnCommands[$K]["join"])) {
            $V = $DB->QuerySingle("SELECT " . $ColumnCommands[$K]["join"][1] . " FROM " . $ColumnCommands[$K]["join"][0] . " WHERE id=:id", array("id" => $Item[$K]));
            $V = $V[$ColumnCommands[$K]["join"][1]];
        }
        if (strlen($V) > 60) {
            $V = substr($V, 0, 57) . "...";
        }
        $V = strip_tags($V);
        $Rows[$I][$K] = $V;
    }
}
// Generate CSV
if (count($Rows) > 0) {
    $Headings = array_keys($Rows[0]);
    $CSVGenerator = new CSVGenerator();
    if (isset($_GET["param_1"]) && $_GET["param_1"] == "test") {
        $CSVGenerator->TestMode = true;
    }
    $CSVGenerator->Headings = $Headings;
    $CSVGenerator->Rows = $Rows;
    $CSVGenerator->Generate();
} else {
    die("No rows to export");
}