PDO::PARAM for type decimal?

前端 未结 4 600
余生分开走
余生分开走 2020-11-28 11:06

I have 2 database fields

`decval` decimal(5,2)
`intval` int(3)

I have 2 pdo queries that update them. The one that updates the int works ok

相关标签:
4条回答
  • 2020-11-28 11:24

    There isn't any PDO::PARAM for decimals / floats, you'll have to use PDO::PARAM_STR.

    0 讨论(0)
  • 2020-11-28 11:28

    UP must use the PDO::PARAM_STR same, and noting that if the column in the database is of type NUMERIC (M, D) or decimal (M, D) should be observed that the M is the number of characters precision should be the total of characters that you can enter, and D the number of decimal places. In the example NUMERIC (10,2) we have 8 houses to places of accuracy and two decimal places. So we have 10 characters in total with 2 reserved for decimal places.

    0 讨论(0)
  • 2020-11-28 11:28

    use PDO::PARAM_STR for all column types which are not of type int or Bool

    0 讨论(0)
  • 2020-11-28 11:33

    I found a solution, send the decimal parameter like PDO::PARAM_STR, in the sql server store procedure receive it like decimal(int,dec)

    PHP

    $stmt_e->bindParam(':valor_escala_desde', $valor_escala_desde, PDO::PARAM_STR);
    

    SQL SERVER, STORE PROCEDURE:

    @valor_escala_desde decimal(18,2),
    

    and is done.

    0 讨论(0)
提交回复
热议问题