Project

General

Profile

Actions

Bug #20427

closed

DBAL - bigint (int8) values get converted to int4 by int-cast

Added by Michael Mondl over 15 years ago. Updated over 14 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2009-05-15
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

In my current project I have to use DBAL with MSSQL 2005 Enterprise.

Before a bigint value is stored to the db (INSERT and UPDATE), the bigint is casted to int by the following statement:
$v = (($mt{0}=='I')||($mt{0}=='F')) ? (int)$v : $v;

This statement can be found in file
typo3/sysext/dbal/class.ux_t3lib_db.php
at line 833 and 761.

Usually (32bit environment) php ints are of type int4 and therefore cut bigint values.

My current workaround is to change both statements to:
$v = (($mt{0}=='I')||($mt{0}=='F')) ? ereg_replace('[^[:digit:]]', '', $v) : $v;

I think this issue is similar to issue #0010965 which describes similiar problems with casting of float values.

PHP: 5.2.6
MSSQL: MSSQL Server 2005 Enterprise Edition
Typo3: 4.2.6
DBAL: 0.9.20
(issue imported from #M11093)


Files

class.ux_t3lib_db.php-patch_v0.9.20 (1.62 KB) class.ux_t3lib_db.php-patch_v0.9.20 Administrator Admin, 2009-06-05 11:43

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #20346: DBAL: Float database field gets converted to integer on insertClosedXavier Perseguers2009-04-23

Actions
Actions #1

Updated by Michael Mondl over 15 years ago

I added a patch which should workaround the problem I described and the issue 0010965.

Actions #2

Updated by Xavier Perseguers about 15 years ago

Hi. I cannot reproduce the bug with PHP5.3.0 on a 32 bit platform. Trying to insert maximal value in 64 bits : 9223372036854775807 is OK.

Can you please provide more information?

Actions #3

Updated by Xavier Perseguers almost 15 years ago

Michael, did you use driver "odbc_mssql" or "mssql"?

Actions #4

Updated by Xavier Perseguers over 14 years ago

No feedback for quite some time now. But after reading it again, the problem is probably that you run a PHP5 in 32 bit while having a database supporting 64 bits numbers. As my environment is fully in 64 bit, I cannot reproduce this behavior.

Furthermore, I don't think it makes sense anyway to locally (= in DBAL) fix this integer cast as I don't see the point being able to insert 64 bit numbers in a database but having to use them as string in PHP as you don't have a 64 bit version of it that handle 64 bit integers.

As such, I won't fix this bug that affect 32 bit version of PHP.

Actions

Also available in: Atom PDF