mirror of
https://github.com/dg/dibi.git
synced 2025-08-10 16:14:57 +02:00
Result: fixed normalization of float when ends with "0" [Closes #189]
This commit is contained in:
@@ -494,7 +494,17 @@ class DibiResult extends DibiObject implements IDataSource
|
||||
$row[$key] = is_float($tmp = $value * 1) ? $value : $tmp;
|
||||
|
||||
} elseif ($type === dibi::FLOAT) {
|
||||
$row[$key] = str_replace(',', '.', ltrim((string) ($tmp = (float) $value), '0')) === ltrim(rtrim(rtrim($value, '0'), '.'), '0') ? $tmp : $value;
|
||||
$value = ltrim($value, '0');
|
||||
$p = strpos($value, '.');
|
||||
if ($p !== FALSE) {
|
||||
$value = rtrim(rtrim($value, '0'), '.');
|
||||
}
|
||||
if ($value === '' || $value[0] === '.') {
|
||||
$value = '0' . $value;
|
||||
}
|
||||
$row[$key] = $value === str_replace(',', '.', (string) ($float = (float) $value))
|
||||
? $float
|
||||
: $value;
|
||||
|
||||
} elseif ($type === dibi::BOOL) {
|
||||
$row[$key] = ((bool) $value) && $value !== 'f' && $value !== 'F';
|
||||
|
Reference in New Issue
Block a user