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

It seems that class constants only cover PDO::PARAM_BOOL , PDO::PARAM_INT and PDO::PARAM_STR for binding. Are you just binding decimal / float / double values ​​as strings or is there a better way to treat them?

MySQLi allows type 'd' for double, it is surprising that PDO has no equivalent when it seems like it is better for many other ways.

+16
database php mysql pdo binding
Aug 26 '09 at 14:22
source share
3 answers

AFAIK PDO :: PARAM_STR is the way to go.

+10
Aug 26 '09 at 14:39
source share

You should use PDO :: PARAM_STR, but for SQLite and other engines this can have unpredictable behavior. See this problem for one example: SQLite HAVING comparison error

0
Jun 29 '16 at 18:24
source share

If you really want to use PDO, you will need to enter it as PARAM_INT , but I never use the specification for double .

This is an optional parameter to indicate the type of PDO .

I think you better not set the PDO type for double s.

-3
Aug 26 '09 at 14:38
source share



All Articles