php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33154 MSSQL fetches for smallmoney and money fields create large numeric strings
Submitted: 2005-05-26 20:03 UTC Modified: 2005-06-04 01:00 UTC
From: jroyer at omegafi dot com Assigned:
Status: No Feedback Package: Sybase (dblib) related
PHP Version: 5.0.4 OS: Red Hat ES 4
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: jroyer at omegafi dot com
New email:
PHP Version: OS:

 

 [2005-05-26 20:03 UTC] jroyer at omegafi dot com
Description:
------------
We are using PHP 5.0.4/Apache 2.0.54 with FreeTDS 0.63 against a SQL Server 2000 server.  When fetching money or smallmoney fields from the database, the return value is a string of size 28 or 24 respectively.  This problem has surfaced when upgrading our web servers from 4.3.2 to 5.0.4.  Version 4.3.2 behaves as expected.

I have used the php.ini-dist out of the box to produce this problem.  The configure line is as follows: 

./configure \
        --with-apxs2=/usr/local/apache/bin/apxs \
        --enable-bcmath \
        --enable-wddx \
        --with-config-file-path=/etc/php4/cgi \
        --with-xml \
        --with-zlib \
        --enable-memory-limit \
        --with-sybase=/usr/local/freetds \
        --enable-magic-quotes=yes \
        --enable-force-cgi-redirect \
        --with-gd \
        --enable-gd-native-ttf \
        --with-zlib-dir=/usr/include \
        --with-jpeg-dir=/usr \
        --with-png-dir=/usr \
        --with-cpdflib=/usr/local \
        --with-ttf=/usr \
        --with-mysql=/usr/include/mysql \
        --with-freetype_dir=/usr/include/freetype2

Reproduce code:
---------------
mssql_connect("Server", "UserName","Password");
mssql_select_db("Database");

$sql="Select SmallMoneyField from Table";
$result = mssql_query($sql);
$row = mssql_fetch_array($result);

while ($row = mssql_fetch_array($result)) {
 	$data[] .= $row["SmallMoneyField"];
        echo $row["TransactionAmount"];
 }

echo strlen($ydata[1]) . '<br>';

Expected result:
----------------
When the code is executed I expect to see a return of a money field with a string length equalling the number of digits (ex. "5.00" should be string length of 4).  Output of the string, when viewing the browser source, shows a number followed by spaces.

Actual result:
--------------
For money fields I get a string length of 28, regardless of the actual number length and a string length of 24 for smallmoney fields.  Other fields, such as text, varchar and integers behave as expected with values matching the number of digits/characters.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-27 08:46 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

Try --with-sybase-ct or --with-mssql instead of --with-sybase.
(both accept same path as you used for --with-sybase!)

 [2005-06-04 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 17:01:30 2024 UTC