msphpsql icon indicating copy to clipboard operation
msphpsql copied to clipboard

New attribute for sql bigint and decimal/numeric types to php int and float types

Open startork opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe.

We are changing our pdo driver from pdo_dblib to pdo_sqlsrv and have issues with bigints and decimals being cast to strings. We pass these values straight to our frontend which does some small calcs for display (totals etc...). I have read through the issues related to this area such as #291 and absolutely agree that by default these types need to be strings to preserve precision. However, a) bigint is the same size as the php int type on most systems b) as mentioned, to do any sort of operation on these values they must be converted to php floats anyway. There is no built-in way to arithmetically handle decimals as decimals in PHP so I don't see the harm in (optionally) always converting these to floats.

Describe the solution you'd like

One or two attributes added to allow default types of int and float for bigint and decimal/numeric types.

Describe alternatives you've considered

Currently I am using a custom version of pdo_sqlsrv with a modified sql_type_to_php_type method.

startork avatar Jan 18 '24 14:01 startork

If you want to add this option you can submit the PR and we can test it and pull it into the a future version.

v-makouz avatar Jan 19 '24 23:01 v-makouz