bigint column return as string with pdo
PHP Driver version or file name
5.8
SQL Server version
18.4
Client operating system
win 10
PHP version
7.3
Microsoft ODBC Driver version
2.3.7
Table schema
a table with bigint column
Problem description
bigint column return as string, i use SQLSRV_ATTR_FETCHES_NUMERIC_TYPE but problem still exist!
Expected behavior and actual behavior
expected return bigint column as integer
Repro code or steps to reproduce
@NVD-R This is by design. Since PHP's integer type is platform-dependent, it may not be wide enough for SQL Server's bigint type, so any bigint fields are returned as strings to avoid loss of data. See the table of default PHP types; also note that the documentation for SQLSRV_ATTR_FETCHES_NUMERIC_TYPE does not list bigints, only smaller types and floats.
@NVD-R closing this issue now as we have answered your questions. Please feel free to reopen if necessary.
Is there any possibity that this will be changed in the future? Even if it's a configurable option. PHP running on 64-bit systems (I assume the vast majority are) can support bigint to PHP int conversions so does it not make sense to allow this as a default PHP type?
Thank you
Worse, I've observed inconsistent behaviour where some systems seem to get the real integer through but others don't running the exact same code? Looks like there's been multiple attempts to PR this fix in but none successful so far.