php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21841 Numeric fields converted to int
Submitted: 2003-01-23 07:58 UTC Modified: 2003-01-23 09:02 UTC
From: herouth at itouch dot co dot il Assigned:
Status: Closed Package: Sybase-ct (ctlib) related
PHP Version: 4.3.0 OS: Linux
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: herouth at itouch dot co dot il
New email:
PHP Version: OS:

 

 [2003-01-23 07:58 UTC] herouth at itouch dot co dot il
When querying a sybase (11.9.2) table field which is defined as numeric(12,6), on the first fetch, the value is typed "float". On the next fetch and onwards, the value is typed "int", so the fractional part is lost.
This behavior did not exist in PHP 4.1, where values were typed "string" when they were numeric.

Example:
(Run in isql)

CREATE TABLE sometable ( val numeric(12,6) )
go
INSERT INTO sometable VALUES (15.5)
INSERT INTO sometable VALUES (14.4)
INSERT INTO sometable VALUES (12.33)
INSERT INTO sometable VALUES (17.18)
go

(PHP script)

<?php
header( 'Content-type: text/plain' );

$conn = sybase_connect( 'host', 'user', 'password' );
sybase_select_db( 'user', $conn );

$res = sybase_query( "SELECT val FROM sometable" );

while ( false !== ( $rec = sybase_fetch_row( $res ) ) ) {

    echo "val = $rec[0]\n";
}
?>

(displayed result)

val = 15.5
val = 14
val = 12
val = 17

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-23 09:02 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 11:01:30 2024 UTC