1
이 링크에서 csv 업로드를 만듭니다. http://www.yiiframework.com/wiki/401/simple-csv-export 형식을 잘못하면 double 값에서 소수점 이하 자릿수가 손실됩니다. 12 (CFormatter는 simple-csv-export 확장자로 십진수를 잃습니다.
foreach ($rows as $row) {
$r = '';
foreach ($coldefs as $col => $config) {
if (isset($row[$col])) {
$val = $row[$col];
FilesFuncs::DebToFile('$col::' . print_r($col, true), false);
FilesFuncs::DebToFile('$val::' . print_r($val, true), false); // HERE $val is WITH decimals
foreach ($config as $conf)
if (!empty($conf)) {
$val = Yii::app()->format->format($val, $conf); // debugging to file : i see result double values returns WITHOUT decimals
...
더블 가격 설명 데이터베이스 필드 :
$dst_filename= 'registers-upto--' . strftime("%Y-%m-%d-%H-%M-%S") . ".csv";
CsvExport::export($GoodsList,
array( 'good_id'=>array('number' ,'fixed8'),
'name'=>array(),
'price'=>array('number' ,'money' ), // MONEY TYPE
'discount'=>array('number' ,'fixed8'),
CsvExport.php 파일에서 :
이 클래스는 내가 실행 제어에서이
<?php
class MyFormatter extends CFormatter
{
...
public function formatMoney($value)
{
FilesFuncs::DebToFile('formatMoney $value::' . print_r($value, true), false); // debugging to file : i see result double values WITHOUT decimals
return round(floatval($value),2);
}
...
처럼 보인다 , 2). 문제는 무엇이며이를 고치는 방법은 무엇입니까? 내가 YII 1.1.14