What is the best way to bind decimal / double / float values with PDO in PHP?

前端 未结 3 739
面向向阳花
面向向阳花 2020-12-03 17:14

It appears the class constants only cover PDO::PARAM_BOOL, PDO::PARAM_INT and PDO::PARAM_STR for binding. Do you just bind decimal / f

相关标签:
3条回答
  • 2020-12-03 17:33

    You have to use PDO::PARAM_STR, but for SQLite and other engines this can have unpredictable behaviors. See this issue for one example: SQLite HAVING comparison error

    0 讨论(0)
  • 2020-12-03 17:42

    AFAIK PDO::PARAM_STR is the way to go.

    0 讨论(0)
  • 2020-12-03 17:45

    If you really want to use PDO you'll have to enter it as an PARAM_INT, but I never use a specification for double.

    It is an optional parameter to specify the PDO type.

    I guess you would better not set the PDO type for doubles.

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