PDO integer changes in 8.1 will stop many websites I support

From: Date: Sat, 27 Feb 2021 08:49:43 +0000
Subject: PDO integer changes in 8.1 will stop many websites I support
Groups: php.internals 
Request: Send a blank email to internals+get-113294@lists.php.net to get a copy of this message
PHP 8.1 PDO has been changed so that when MySQL returns an integer it will no longer be returned as a string, but as an int.

The problem is this breaks any sites that use UNSIGNED ZEROFILL integer fields in MySQL.

I support a number of websites where the phone numbers and post codes are all UNSIGNED ZEROFILL.

The post codes in MySQL are stored as 0800.

In PHP 8.0 returned as string 0800
In PHP 8.1 returned as integer 800

8.0.2
string(10) "0742000000"

8.1.0-dev
int(742000000)

PDO shouldn't really be changing the data.

I propose that:
• any ZEROFILL integers are returned as string [or]
• there's an option to control this when making the connection (I don't want to str_pad() at every place I've used ZEROFILL in the past) [or]
• this backwards compatibility breaking change is removed until PHP 9.

Matthew Asia


Thread (10 messages)

« previous php.internals (#113294) next »