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

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


AFAIK PDO::PARAM_STR is the way to go.


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


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.