|  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
 [2010-03-05 10:36 UTC] alexr at oplot dot com
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';
$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');
$r = $sth->fetchAll(2);

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

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


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

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



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

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-08 13:39 UTC]
Automatic comment from SVN on behalf of iliaa
Log: Fixed bug #51213 (pdo_mssql is trimming value of the money column).
 [2010-03-08 13:39 UTC]
-Status: Open +Status: Closed
 [2010-03-08 13:39 UTC]
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
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-2023 The PHP Group
All rights reserved.
Last updated: Fri Sep 29 21:01:25 2023 UTC