php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22341 Strange Rounding Problem with Money Fields
Submitted: 2003-02-20 17:26 UTC Modified: 2003-02-25 17:29 UTC
From: ryanphpb at ryanjameson dot com Assigned:
Status: Closed Package: Sybase-ct (ctlib) related
PHP Version: 4.3.1 OS: windows 2000
Private report: No CVE-ID: None
 [2003-02-20 17:26 UTC] 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.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-20 17:40 UTC] 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:56 UTC] 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-25 16:30 UTC] 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-25 17:29 UTC] iliaa@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 05:01:30 2024 UTC