Re: PDO_DBLIB type handling
| From: | Matteo Beccati | Date: | Sun, 22 Feb 2015 10:45:32 +0000 |
| Subject: | Re: PDO_DBLIB type handling | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-83467@lists.php.net to get a copy of this message | ||
On 21/02/2015 23:12, Yasuo Ohgaki wrote:
Hi Adam, On Sat, Feb 21, 2015 at 2:22 AM, Adam Baratz <adam.baratz@gmail.com> wrote:The default behaviour of mysql/pgsql drivers is to convert to the matching PHP type, if possible. That can be turned off via PDO::ATTR_STRINGIFY_FETCHES => true. If PDO_DBLIB doesn't behave like that, I'd say it's a bug that needs to be fixed, but possibly only applied to a major/minor release due to the BC break. Cheers -- Matteo Beccati Development & Consulting - http://www.beccati.com/This driver returns all column data as a string, regardless of how it's represented in the DB. I created a patch for my own use that syncs up the type handling with the behavior of the MSSQL extension. This seems like it would be of general use. Does anyone have any feedback before I put together an RFC? My main question would be whether people would rather have this be the default/only behavior, or whether it should be opted into via PDO::ATTR_STRINGIFY_FETCHES.Databases return "string" data to return correct data in DB. Most obvious is "NUMERIC" data type. NUMERIC has any precision. We may have 128 bit INT in near future also. So it should return string by default, PHP may convert types into PHP native types optionally. Not the other way around. IMHO.