Last active
December 3, 2015 08:02
-
-
Save RyujiAMANO/809c942f1edf21a329d0 to your computer and use it in GitHub Desktop.
CSVとZIPの雰囲気
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 | |
$questionnaire = $this->_getQuestionnaireForAnswerCsv($questionnaireKey); | |
$csv = new CsvExporter(); | |
// 回答データを一気に全部取得するのは、データ爆発の可能性があるので | |
// QUESTIONNAIRE_CSV_UNIT_NUMBER分に制限して取得する | |
$offset = 0; | |
do { | |
$datas = $this->QuestionnaireAnswerSummaryCsv->getAnswerSummaryCsv($questionnaire, QuestionnairesComponent::QUESTIONNAIRE_CSV_UNIT_NUMBER, $offset); | |
foreach ($datas as $data) { | |
$csv->append($data); | |
} | |
$dataCount = count($datas); // データ数カウント | |
$offset += $dataCount; // 次の取得開始位置をずらす | |
} while ($dataCount == QuestionnairesComponent::QUESTIONNAIRE_CSV_UNIT_NUMBER); | |
// データ取得数が制限値分だけとれている間は繰り返す | |
$csv->setPassword($this->Auth->user('username')); | |
return $csv->doDownlaod(); |
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 | |
$questionnaire = $this->_getQuestionnaireForAnswerCsv($questionnaireKey); | |
$csvFile = new CsvFileWriter(); | |
// 回答データを一気に全部取得するのは、データ爆発の可能性があるので | |
// QUESTIONNAIRE_CSV_UNIT_NUMBER分に制限して取得する | |
$offset = 0; | |
do { | |
$datas = $this->QuestionnaireAnswerSummaryCsv->getAnswerSummaryCsv($questionnaire, QuestionnairesComponent::QUESTIONNAIRE_CSV_UNIT_NUMBER, $offset); | |
foreach ($datas as $data) { | |
$csvFile->append($data); | |
} | |
$dataCount = count($datas); // データ数カウント | |
$offset += $dataCount; // 次の取得開始位置をずらす | |
} while ($dataCount == QuestionnairesComponent::QUESTIONNAIRE_CSV_UNIT_NUMBER); | |
// データ取得数が制限値分だけとれている間は繰り返す | |
$zipFile = new ZipFile(); | |
$zipFile->append($csvFile); | |
$zipFile->setPassword($this->Auth->user('username')); | |
return $zipFile->doDownlaod(); |
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 | |
$zipFolder = new ZipFolder(); | |
$csvWriter = new CsvFileWriter(['folder' => $zipFolder->path]); | |
// $csvWriterゴニョニョ | |
$zipFolder->archive('password'); | |
return $zipFolder->downlaod(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment