From 7cee7997e227285307ec0364e41e073dae49a519 Mon Sep 17 00:00:00 2001 From: Ciki Date: Tue, 11 Feb 2014 17:04:19 +0100 Subject: [PATCH] fix casting to float Now, when sql returns float from (0,1) interval, e.g. '.842' - the decimal part is missing & it won't get cast to float. This is fix for that situation --- dibi/libs/DibiResult.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dibi/libs/DibiResult.php b/dibi/libs/DibiResult.php index f1d500d7..983106b7 100644 --- a/dibi/libs/DibiResult.php +++ b/dibi/libs/DibiResult.php @@ -514,7 +514,7 @@ class DibiResult extends DibiObject implements IDataSource $row[$key] = is_float($tmp = $value * 1) ? $value : $tmp; } elseif ($type === dibi::FLOAT) { - $row[$key] = (string) ($tmp = (float) $value) === rtrim(rtrim($value, '0'), '.') ? $tmp : $value; + $row[$key] = ltrim((string) ($tmp = (float) $value), '0') === ltrim(rtrim(rtrim($value, '0'), '.'), '0') ? $tmp : $value; } elseif ($type === dibi::BOOL) { $row[$key] = ((bool) $value) && $value !== 'f' && $value !== 'F';