Hi All,
I've run into this really annoying behavior and I want to know if I'm doing something wrong, or if this is intentional (and if so, why).
Whenever I have a variable in php (5.3) that is of type double and I want to insert it into the database (MYSQL 5.0) in a field that is of type double, the value always gets rounded down to 6 digits behind the point when I'm using PDO. So the below code:
$stmt = $pdo->prepare("UPDATE someTable SET someDouble = :somePHPDouble;");
$number = 0.11124379542256;
$stmt->bindValue(':somePHPDouble', $number);
$stmt->execute();
Results in 0.111244 inserted into the db. But when I cast the variable to a string(!) in the binding expression like:
$stmt->bindValue(':somePHPDouble', (string)$number);
it inserts it properly as 0.11124379542256.
What is happening here ? I'm clueless. MySQL datatype of someDouble really is a double, and when inserting it through mysql console it just works. And the variable in php really is a double, so it seems to me that something goes wrong inside PDO.
Thanks in advance, -CodePoet.