diff options
-rw-r--r-- | it_dbi.class | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/it_dbi.class b/it_dbi.class index ec152d7..09ff18d 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -596,7 +596,7 @@ function iterate() unset($this->$field); foreach ($this->_data as $field => $value) - $this->$field = isset($value) && $this->_isint[$field] ? ($this->_data[$field] = intval($value)) : $value; + $this->$field = (isset($value) && $this->_convertfunc[$field]) ? ($this->_data[$field] = $this->_convertfunc[$field]($value)) : $value; if ($localizedfields) { @@ -764,7 +764,8 @@ function _get_field_info() for ($res = $this->query('SHOW COLUMNS FROM ' . $this->_p['table']); $res && ($field = mysql_fetch_assoc($res)); ) { $this->_fields[$field['Field']] = $field + array('Length' => preg_match('/date|time/', $field['Type']) ? 20 : intval(it::match('\d+', $field['Type']))); - $this->_isint[$field['Field']] = preg_match('/^(tiny|small|medium|)int/', $field['Type']); + if (preg_match('/^(tiny|small|medium|)int|^float|^double/', $field['Type'])) + $this->_convertfunc[$field['Field']] = it::match('int', $field['Type']) ? "intval" : "floatval"; } # Consider all fields which have _{localized_defaultlanguage} suffix as localized @@ -773,11 +774,11 @@ function _get_field_info() $state = it_dbi::_state_get($dbid); # State could have been modified by query above $state['fields'][$this->_p['table']] = $this->_fields; - $state['isint'][$this->_p['table']] = $this->_isint; + $state['convertfunc'][$this->_p['table']] = $this->_convertfunc; it_dbi::_state_put($dbid, $state); } else # Existing _fields, copy other info too - $this->_isint = $state['isint'][$this->_p['table']]; + $this->_convertfunc = $state['convertfunc'][$this->_p['table']]; foreach((array)$this->_fields as $field) { |