You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
create a table with one decimal column (or numeric )
insert one row of valid data
write a stored procedure to fetch the value of this decimal column as output parameter
use prepare() to call this stored procedure
bind this output parameter to PDO::PARAM_INT or PDO::PARAM_BOOL
after execute(), the output param is a float, not integer as expected
For example, a table is created with a decimal(4, 1) column,
if the input is 922.337, the data fetched as output param is 922.3, or
if the input is -922.337, the data fetched as output param is -922.3
If binding the variable as an inout parameter with type PDO::PARAM_INT, and the variable is initialized to an integer, then this problem goes away.
Without AE, given the same inputs above, the output params are 922 and -922 respectively with type PDO::PARAM_INT, or bool(true) / bool(false) as with type PDO::PARAM_BOOL
The text was updated successfully, but these errors were encountered:
yitam
changed the title
AE - fetching decimals / numerics are output parameters bound to PDO::PARAM_BOOL or PDO::PARAM_INT returns floats, not integers
AE - fetching decimals / numerics as output parameters bound to PDO::PARAM_BOOL or PDO::PARAM_INT returns floats, not integers
Mar 7, 2018
To reproduce,
For example, a table is created with a decimal(4, 1) column,
if the input is 922.337, the data fetched as output param is 922.3, or
if the input is -922.337, the data fetched as output param is -922.3
If binding the variable as an inout parameter with type PDO::PARAM_INT, and the variable is initialized to an integer, then this problem goes away.
Without AE, given the same inputs above, the output params are 922 and -922 respectively with type PDO::PARAM_INT, or bool(true) / bool(false) as with type PDO::PARAM_BOOL
The text was updated successfully, but these errors were encountered: