#22341 [Opn->Csd]: Strange Rounding Problem with Money Fields
| From: | iliaa@php.net | Date: | Tue, 25 Feb 2003 23:29:07 +0000 |
| Subject: | #22341 [Opn->Csd]: Strange Rounding Problem with Money Fields | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-34269@lists.php.net to get a copy of this message | ||
ID: 22341
Updated by: iliaa@php.net
Reported By: ryanphpb at ryanjameson dot com
-Status: Open
+Status: Closed
Bug Type: Sybase-ct (ctlib) related
Operating System: windows 2000
PHP Version: 4.3.1
New Comment:
This bug has been fixed in CVS.
In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2003-02-25 16:30:17] ryanphpb at ryanjameson dot com
That fixed it! I didn't install the whole build, just the
php_sybase_ct.dll, but it works great! The files in the version I have
are dated 2/25. Feel free to close this.
------------------------------------------------------------------------
[2003-02-22 14:28:55] iliaa@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
------------------------------------------------------------------------
[2003-02-20 17:56:00] ryanphpb at ryanjameson dot com
PHP 4.3.1 ctlib
Steps to reproduce, connect to a sybase database table with a money
field and multiple rows...
"select moneyField from table"
loop through the result and echo the value of the moneyField.
The first row will be acurate for the decimal places each row after
will not. sybase_data_seek up 4 or 5 rows and you'll find you still
don't have your decimal places. If you do a select that begins with the
second result in your first select you'll find that the decimal
magically appears on that row since it is the first result in the set
but following rows have no decimals.
------------------------------------------------------------------------
[2003-02-20 17:40:07] ryanphpb at ryanjameson dot com
NO!!!! Sorry about that the sample I gave you is not accurate. It turns
out that the decimal values are only available for the first row in the
record set. All consecutive rows after simply have the decimal chopped
off.
Here's a sample:
while ($ar=sybase_fetch_array($rs)){
echo $ar['purchaseprice']."<br>";
}
returns:
24.72
0
3
0
0
0
17
19
0
64
0
52
0
24
0
0
0
0
0
24
while the actual values are:
24.72
0.00
3.51
0.00
0.00
0.00
17.65
19.10
0.00
64.56
0.00
52.80
0.00
24.72
0.00
0.00
0.00
0.00
0.00
24.72
------------------------------------------------------------------------
[2003-02-20 17:26:00] ryanphpb at ryanjameson dot com
There's an old report #13807 that sounds similar to what I'm
experiencing. The issue is that a value of 11.16 is coming back in my
result array as 11. Other values in the same field in the same result
are coming back fine, ie... the previous value was 111.6. So for some
reason this field is rounding wrong but just for this value. When I
look at it through ODBC with MS Access I see 11.16.
--------------------------------
$q = "select producthandle.sellingprice from customerorder,
producthandle where producthandle.id = customerorder.nr and
customerorder.nr = '030216-22782' and class='CO'";
$con = sybase_connect("#server#","#user#","#password#");
$rs = sybase_query($q,$con);
while ($ar=sybase_fetch_array($rs)){
echo $ar['sellingprice'] . "<br>";
}
------------------------ OUTPUT:
111.6
11
33.4
555.3
12.31
1.23
------------------------
The 11 should be 11.16...
The field type is native sybase money.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22341&edit=1