php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51213 pdo_mssql is trimming value of the money column
Submitted: 2010-03-05 10:36 UTC Modified: 2010-03-08 13:39 UTC
From: alexr at oplot dot com Assigned: iliaa (profile)
Status: Closed Package: PDO related
PHP Version: 5.2.13 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alexr at oplot dot com
New email:
PHP Version: OS:

 

 [2010-03-05 10:36 UTC] alexr at oplot dot com
Description:
------------
Money column is wrongly converting to the char column and this cause that value is rounding to the 2 digits after delimiter (dot).

Test script:
---------------
$dsn = 'mssql:dbname=DBNAME;host=HOSTNAME';
$user = 'USERNAME';
$password='PASSWORD';
$dbh = new PDO($dsn, $user, $password);
$sth = $dbh->query  ('create table #tmp(col money)');
$sth = $dbh->query  ('insert into #tmp(col) values(-0.1234)');
$sth = $dbh->query  ('insert into #tmp(col) values(0.1234)');
$sth = $dbh->prepare('select * from #tmp');
$sth->execute();
$r = $sth->fetchAll(2);
print_r($r);

Expected result:
----------------
Array
(
    [0] => Array
        (
            [col] => -0.1234
        )

    [1] => Array
        (
            [col] => 0.1234
        )

)

Actual result:
--------------
Array
(
    [0] => Array
        (
            [col] => -0.12
        )

    [1] => Array
        (
            [col] => 0.12
        )

)

Patches

pdo_mssql_money_column_conversion_fix (last revision 2010-03-05 09:38 UTC by alexr at oplot dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-08 13:39 UTC] iliaa@php.net
Automatic comment from SVN on behalf of iliaa
Revision: http://svn.php.net/viewvc/?view=revision&revision=295958
Log: Fixed bug #51213 (pdo_mssql is trimming value of the money column).
 [2010-03-08 13:39 UTC] iliaa@php.net
-Status: Open +Status: Closed
 [2010-03-08 13:39 UTC] iliaa@php.net
This bug has been fixed in SVN.

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/.
 
Thank you for the report, and for helping us make PHP better.


 [2010-08-05 21:48 UTC] rgagnon24 at gmail dot com
This closed bug which was recently made part of the 5.2.14 release causes segmentation fault when a money type is fetched.

The patch supplied "pdo_mssql_money_column_conversion_fix" "last revision 2010-03-05 09:38 UTC" works, but the committed code does not.

The spprintf() call is the cause of the segmentation fault as it is sending incompatible pointer val->data as parameter 1 which appears to be uninitialized pointer.  (val->data was never emalloc'd) 

Anyone using pdo_dblib will get a seg fault attempting to iterate results with money results.
 [2010-08-05 22:13 UTC] rgagnon24 at gmail dot com
New bug opened as bug 52546 to deal with this new issue.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC