summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_dbi.class6
-rwxr-xr-xtests/it_dbi.t6
2 files changed, 9 insertions, 3 deletions
diff --git a/it_dbi.class b/it_dbi.class
index bc640b3..b2c78ef 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -491,11 +491,11 @@ function iterate()
{
if ($this->_data = mysql_fetch_assoc($this->_result))
{
+ foreach ($this->_data as $field => $value)
+ $this->$field = ($this->_fields[$field]['Type'] == 'int(11)') ? ($this->_data[$field] = intval($value)) : $value;
+
if (!empty($this->_p['keyfield']))
$this->_key = $this->_data[$this->_p['keyfield']];
-
- foreach ($this->_data as $field => $value)
- $this->$field = $value;
}
else
$this->clear(false);
diff --git a/tests/it_dbi.t b/tests/it_dbi.t
index 8ef8cab..82826f1 100755
--- a/tests/it_dbi.t
+++ b/tests/it_dbi.t
@@ -92,3 +92,9 @@ is(
array(3, $rand, "quux"),
"iterate update record 3"
);
+
+is(
+ gettype($record->_key) . "/" . gettype($record->x) . "/" . gettype($record->_data['x']) . "/" . gettype($record->foo),
+ "integer/integer/integer/string",
+ "automatic type detection"
+);