本文整理汇总了PHP中FileManager::putCSV方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::putCSV方法的具体用法?PHP FileManager::putCSV怎么用?PHP FileManager::putCSV使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager::putCSV方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exportCustomCSV
public function exportCustomCSV()
{
$custom_query = Tools::post('custom_query');
$csvSeparator = Tools::post('csv_separator');
$headerRow = Tools::post('with_header_row');
$csv_file_name = Tools::post('csv_file_name');
$fileName = TMP . $csv_file_name . '.csv';
$fp = fopen($fileName, 'w');
$this->DB->SetFetchMode(ADODB_FETCH_ASSOC);
$result = $this->DB->Execute($custom_query);
$errorMsg = $this->DB->ErrorMsg();
if ($errorMsg != "") {
FlashSession::setFlash('error', $errorMsg);
return false;
}
$cp = 0;
if ($result !== false) {
while (!$result->EOF) {
$aRecords = $result->fields;
if ($headerRow && $cp == 0) {
FileManager::putCSV($fp, $aRecords, $csvSeparator, '', true);
}
FileManager::putCSV($fp, $aRecords, $csvSeparator, '');
$result->MoveNext();
$cp++;
}
}
fclose($fp);
FileManager::downloadCSVFile($fileName);
}
示例2: runCSVExport
/**
* @param $fileName
* @param $tableName
* @param $importFieldsType
* @param $fieldsList
* @param $csvSeparator
* @param $exportFieldsName
*/
private function runCSVExport($fileName, $tableName, $importFieldsType, $fieldsList, $csvSeparator, $exportFieldsName)
{
$fileName = $fileName . '.csv';
$fp = fopen($fileName, 'w');
if ($exportFieldsName) {
FileManager::putCSV($fp, $fieldsList, $csvSeparator, '');
}
if ($importFieldsType == "all") {
$query = "SELECT * FROM {$tableName}";
} else {
$query = "SELECT " . implode(",", $fieldsList) . " FROM {$tableName}";
}
$format = "Exported rows : %current%/%max% [%bar%] %percent% (%elapsed%)";
$filler = '=>';
$empty = ' ';
$width = 100;
$cp = 0;
$result = $this->DB->Execute($query);
if ($result !== false) {
$count = $result->_numOfRows;
/**
* Init Progress Bar
*/
$bar = new Console_ProgressBar($format, $filler, $empty, $width, $count);
while (!$result->EOF) {
$aRecords = $result->fields;
FileManager::putCSV($fp, $aRecords, $csvSeparator, '');
$result->MoveNext();
$cp++;
$bar->update($cp);
}
$this->showNotice("Export has been successfully finished : " . $cp . " rows exported.");
}
fclose($fp);
$errorMsg = $this->DB->ErrorMsg();
if ($errorMsg != "") {
$this->showError($errorMsg);
}
}