Closed DannyRidgway closed 2 years ago
Decimal/numeric are treated as strings because they don't quite map to a C/PHP type without accuracy loss. While a five-digit decimal without mantissa could fit as integer/float, it'd be harder for say, a decimal(10, 2)
- you'd lose the decimal information as an int, and floating point isn't accurate enough for a non-lossy conversion.
I'd say cast it - you imply PHP level would be too much effort, but what about at the SQL level? An SQL integer/float will have the same representation.
Thanks
Just a small question regarding expected functionality. I could not find it in the docs but should the values returned from db2_fetch_assoc match the same types as the table/field definition?
E.g. ITEMID = VARCHAR 68 ITEMSEQN = DECIMAL 5
In the associative array I would expect the ITEMID to be a string which it is however the ITEMSEQN field is also returned as a string type.
Is this how it's meant to work? I would have expected numerical fields to be returned as a int or double in PHP.
If so do you know of a way to force the types returned from db2_fetch_assoc to be the correct type?
I could manually correct it in our project however this function is used around 1000 times and the effort required would be enormous.