Open wmiguellima opened 1 year ago
While the documentation doesn't appear to clarify this, I don't think that returning strings for numeric column values qualifies as bug. E.g. there is fetch.phpt which actually expects strings in this case. Furthermore, changing the behavior in stable versions might cause more harm than good (besides that values which would exceed PHP's int
range would still need to be returned as strings).
So I'm changing this to feature request, although transferring to doc-en might be the more sensible thing to do.
Just to give more context, we have an application that works flawlessly with MySQL/MariaDB/SQL Server, thanks to Laravel Eloquent ORM and no usage of specific syntax. We are trying to add support to Oracle (21c) and right now this is the only thing that is preventing us to do that. The code base is huge, so it is unfeasible to cast the applicable values.
What about create an option, like @wmiguellima proposes, to opt-in for number columns as int
(sure, as long as the value doesn't exceeed PHP's int
range)?
Description
The following code:
Resulted in this output:
But I expected this output instead:
Problem:
The integer columns are being converted to strings.
Using CAST is not an option.
Possible solution:
Something like
PDO::ATTR_STRINGIFY_FETCHES
available on de sqlserver pdoPHP Version
PHP 8.1
Operating System
Ubuntu 20.04