[Flow] export to .csv
Andre Hohmann
mail at andre-hohmann.net
Tue Apr 28 14:39:32 CEST 2015
Hallo,
I want to export the class Mitglied to a csv-file. In my
MitgliedRepository I make a query like this:
public function findTennis() {
$query = $this->createQuery();
$result = $query->matching($query->equals('abteilung', 'Tennis'))
->setOrderings(array('name' =>
TYPO3FlowPersistenceQueryInterface::ORDER_ASCENDING))
->execute();
return $result;
}
In my controller I tried this:
public function exportTennisAction() {
// find all mitglieder with abteilung Tennis
$records = $this->mitgliedRepository->findTennis();
$csvPath =
'/var/www/apps/flow/Packages/Application/ITOOP.Atc/Resources/Private/Export/test.csv';
$fp = fopen($csvPath, 'w');
foreach ($records as $lines) {
fputcsv($fp, $lines);
}
fclose($fp);
}
When I call the exportTennisAction, I get the following:
#1: WARNING: FPUTCSV() EXPECTS PARAMETER 2 TO BE ARRAY, OBJECT GIVEN IN
/VAR/WWW/APPS/FLOW/DATA/TEMPORARY/DEVELOPMENT/CACHE/CODE/FLOW_OBJECT_CLASSES/ITOOP_ATC_CONTROLLER_MITGLIEDCONTROLLER.PHP
LINE 492
Line 492 is:
fputcsv($fp, $lines);
Do I have to format the output of $records to arrays? How should I do
that?
Thank you!
--
Mit freundlichen Grüssen
Andre
---------------------------------------------------------------------------------------------
http://www.andre-hohmann.net
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren und die unbefugte Weitergabe dieser E-Mail sind nicht gestattet.
More information about the Flow
mailing list