Skip to content

Commit

Permalink
Database: ResultSet converts to float numbers like .123 (returned by …
Browse files Browse the repository at this point in the history
…SQL Server)
  • Loading branch information
dg committed Apr 15, 2013
1 parent 879849b commit 0c2ebef
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Database/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ public function normalizeRow($row)
$row[$key] = is_float($tmp = $value * 1) ? $value : $tmp;

} elseif ($type === IReflection::FIELD_FLOAT) {
$value = strpos($value, '.') === FALSE ? $value : rtrim(rtrim($value, '0'), '.');
if (($pos = strpos($value, '.')) !== FALSE) {
$value = rtrim(rtrim($pos === 0 ? "0$value" : $value, '0'), '.');
}
$float = (float) $value;
$row[$key] = (string) $float === $value ? $float : $value;

Expand Down

0 comments on commit 0c2ebef

Please sign in to comment.