|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-12-01 11:00 UTC] ilpochta at gmail dot com
Description:
------------
When SQL query returns numbers with precision 7, 8 or 12-14 (digits after period) ibase_fetch_*() returns these numbers divided by 10.
When precision are 18 - returns "29".
I was tested this on PHP 5.2, 5.1.6; on WinXP and RedHat Linux; on Firebird 1.5 and 2.
Maybe, this is some bug with #39056 ?
Reproduce code:
---------------
//generate SQL
$nums=array();
for($i=0;$i<=18;$i++) {
$nums[]=sprintf('1.%s AS prc_%d', str_repeat('0',$i), $i);
}
$stmt='SELECT '. implode(', ',$nums). ' FROM RDB$DATABASE';
//query
$dbh = ibase_connect('localhost:c:/main.gdb', 'SYSDBA', 'masterkey');
$sth = ibase_query($dbh, $stmt) or die(ibase_errmsg());
$res=ibase_fetch_assoc($sth);
print_r($res);
Expected result:
----------------
PHP 4 outputs:
Array
(
[PRC_0] => 1
[PRC_1] => 1.0
[PRC_2] => 1.00
[PRC_3] => 1.000
[PRC_4] => 1.0000
[PRC_5] => 1.00000
[PRC_6] => 1.000000
[PRC_7] => 1.0000000
[PRC_8] => 1.00000000
[PRC_9] => 1.000000000
[PRC_10] => 1.0000000000
[PRC_11] => 1.00000000000
[PRC_12] => 1.000000000000
[PRC_13] => 1.0000000000000
[PRC_14] => 1.00000000000000
[PRC_15] => 1.000000000000000
[PRC_16] => 1.0000000000000000
[PRC_17] => 1.00000000000000000
[PRC_18] => 1.000000000000000000
)
Actual result:
--------------
Array
(
[PRC_0] => 1
[PRC_1] => 1.0
[PRC_2] => 1.00
[PRC_3] => 1.000
[PRC_4] => 1.0000
[PRC_5] => 1.00000
[PRC_6] => 1.000000
[PRC_7] => 0.10000000
[PRC_8] => 0.100000000
[PRC_9] => 1.000000000
[PRC_10] => 1.0000000000
[PRC_11] => 1.00000000000
[PRC_12] => 0.1000000000000
[PRC_13] => 0.10000000000000
[PRC_14] => 0.100000000000000
[PRC_15] => 1.000000000000000
[PRC_16] => 0.10000000000000000
[PRC_17] => 0.100000000000000000
[PRC_18] => 29.008656684181574799
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 07:00:01 2025 UTC |
Take the solution from #39056, add two strings to them (for precisions 17 and 18) and .... it works! :) # diff ./php-5.2.0/ext/interbase/old/ibase_query.c ./fixed/ext/interbase/ibase_query.c 1289,1291c1289,1304 < static ISC_INT64 const scales[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 100000000, 1000000000, < 1000000000, LL_LIT(10000000000),LL_LIT(100000000000),LL_LIT(10000000000000),LL_LIT(100000000000000), < LL_LIT(1000000000000000),LL_LIT(1000000000000000),LL_LIT(1000000000000000000) }; --- > static ISC_INT64 const scales[] = { 1, 10, 100, 1000, > 10000, > 100000, > 1000000, > 10000000, > 100000000, > 1000000000, LL_LIT > (10000000000),LL_LIT > (100000000000),LL_LIT > (1000000000000),LL_LIT > (10000000000000),LL_LIT > (100000000000000),LL_LIT > (1000000000000000),LL_LIT > (10000000000000000),LL_LIT > (100000000000000000),LL_LIT > (1000000000000000000) }; ---------- I think, same error is present in function firebird_stmt_get_col() from ext/pdo_firebird/firebird_statement.c .