Making Format I Lose Decimals In Double Values

Hi all,

I make csv upload from this link link

and found error that making format I lose decimals in double values.

I made such class :


<?php


class MyFormatter extends CFormatter

{

...

public function formatMoney($value)

{

	FilesFuncs::DebToFile('formatMoney  $value::' . var_dump($value), false); // debugging to file : i see result double values WITHOUT decimals IT HAS VALUE string(2) "23"

	return round(floatval($value),2);

}

...


In control I run :

$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' ),


In CsvExport.php file :


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::' . var_dump($val), false); // HERE $val is WITH decimals  IT SHOW string(5) "23.40" value

       foreach ($config as $conf)

         if (!empty($conf)) {

           $val = Yii::app()->format->format( $val, $conf ); // debugging to file :CALLING IT IT LOSE DECIMALS

...



In database field described as price double(12,2).

Yii 1.1.14

Commas (’,’) is used to separate between numbers and decimal places in my OS.

I make debugging of the code and can not find WHY calling Yii::app()->format->format inside of this method decimals are lost ?

Is it some feature of CFormatter ?

Hi,

I think you should such formatting code inside afterfind method. It will solve your problems