Source for file SC_Helper_CSV.php
Documentation is available at SC_Helper_CSV.php
* Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* @author LOCKON CO.,LTD.
* @version $Id: SC_Helper_CSV.php 17799 2009-02-17 14:19:20Z Seasoft $
$this->arrPref =
$masterData->getMasterData("mtb_pref",
array("pref_id", "pref_name", "rank"));
$this->arrSex =
$masterData->getMasterData("mtb_sex");
$this->arrDISP =
$masterData->getMasterData("mtb_disp");
$this->arrRECOMMEND =
$masterData->getMasterData("mtb_recommend");
* @param integer $csv_id CSV ID
* @param string $where SQL の WHERE 句
* @param array $arrVal WHERE 句の要素
* @return array CSV 項目の配列
function sfgetCsvOutput($csv_id =
"", $where =
"", $arrVal =
array()){
$sql .=
" create_date, ";
$sql .=
" WHERE csv_id = ? ";
$arrData =
array($csv_id);
$ret =
$objQuery->getall($sql, $arrData);
if (count($arrOutput) <=
0) return false; // 失敗終了
$arrOutputCols =
$arrOutput['col'];
$objQuery->setorder($order);
$dataRows =
$objQuery->select(
SC_Utils_Ex::sfGetCommaList($arrOutputCols, true, array('category_id'))
,'vw_product_class AS prdcls'
if (in_array('classcategory_id1', $arrOutputCols) ||
in_array('classcategory_id2', $arrOutputCols)) {
$arrClassCatName =
$objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
$outputArray[] =
$arrOutput['disp_name'];
foreach ($dataRows as $row) {
if (in_array('classcategory_id1', $arrOutputCols)) {
$row['classcategory_id1'] =
$arrClassCatName[$row['classcategory_id1']];
if (in_array('classcategory_id2', $arrOutputCols)) {
$row['classcategory_id2'] =
$arrClassCatName[$row['classcategory_id2']];
if (in_array('category_id', $arrOutputCols)) {
$row['category_id'] =
$objQuery->getCol("dtb_product_categories",
array($row['product_id']));
$from =
"dtb_review AS A INNER JOIN dtb_products AS B on A.product_id = B.product_id ";
$objQuery->setoption($option);
$list_data =
$objQuery->select($cols, $from, $where, $arrval);
$max =
count($list_data);
if (!isset
($data)) $data =
"";
for($i =
0; $i <
$max; $i++
) {
// CSV出力データを作成する。(トラックバック)
$from =
"dtb_trackback AS A INNER JOIN dtb_products AS B on A.product_id = B.product_id ";
$objQuery->setoption($option);
$list_data =
$objQuery->select($cols, $from, $where, $arrval);
$max =
count($list_data);
if (!isset
($data)) $data =
"";
for($i =
0; $i <
$max; $i++
) {
if (count($arrOutput) <=
0) return false; // 失敗終了
$arrOutputCols =
$arrOutput['col'];
$objQuery->setorder('rank DESC');
$dataRows =
$objQuery->select(
$outputArray[] =
$arrOutput['disp_name'];
foreach ($dataRows as $row) {
function lfGetCSV($from, $where, $option, $arrval, $arrCsvOutputCols =
"") {
$cols =
SC_Utils_Ex::sfGetCommaList($arrCsvOutputCols);
$objQuery->setoption($option);
$list_data =
$objQuery->select($cols, $from, $where, $arrval);
$max =
count($list_data);
if (!isset
($data)) $data =
"";
for($i =
0; $i <
$max; $i++
) {
foreach($list as $key =>
$val) {
$tmp =
$this->arrPref[$val];
$line .=
"\"".
$tmp.
"\",";
$line =
$this->replaceLineSuffix($line);
// 各項目をCSV出力用に変換する。(レビュー)
foreach($list as $key =>
$val) {
$tmp = isset
($this->arrSex[$val]) ?
$this->arrSex[$val] :
"";
$tmp = isset
($this->arrRECOMMEND[$val]) ?
$this->arrRECOMMEND[$val]
$tmp = isset
($this->arrDISP[$val]) ?
$this->arrDISP[$val] :
"";
$line .=
"\"".
$tmp.
"\",";
$line =
$this->replaceLineSuffix($line);
// 各項目をCSV出力用に変換する。(トラックバック)
foreach($list as $key =>
$val) {
$tmp =
$this->arrTrackBackStatus[$val];
$line .=
"\"".
$tmp.
"\",";
$line =
$this->replaceLineSuffix($line);
* @param string $line CSV出力用の1行分の文字列
* @return string 行末の ',' を CRLF に変換した文字列
function replaceLineSuffix($line) {
* 参考: http://jp.php.net/fputcsv
function sfArrayToCsv($fields, $delimiter =
',', $enclosure =
'"', $arrayDelimiter =
'|') {
if( strlen($delimiter) !=
1 ) {
trigger_error('delimiter must be a single character', E_USER_WARNING);
if( strlen($enclosure) <
1 ) {
trigger_error('enclosure must be a single character', E_USER_WARNING);
$field =
implode($arrayDelimiter, $field);
/* enclose a field that contains a delimiter, an enclosure character, or a newline */
$field =
$enclosure .
preg_replace('/' .
preg_quote($enclosure) .
'/', $enclosure .
$enclosure, $field) .
$enclosure;
return implode($delimiter, $fields);
$file_name =
$dir_name .
date("ymdHis") .
".csv";
$file_name =
$prefix .
date("ymdHis") .
".csv";
Header("Content-disposition: attachment; filename=${file_name}");
Header("Content-type: application/octet-stream; name=${file_name}");
Header("Cache-Control: ");
foreach ($arrayData as $lineArray) {
Documentation generated on Tue, 28 Apr 2009 18:13:24 +0900 by phpDocumentor 1.4.2