summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_dbi.class3
-rwxr-xr-xtest/it_dbi.t11
2 files changed, 14 insertions, 0 deletions
diff --git a/it_dbi.class b/it_dbi.class
index 426e653..be802b7 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -680,6 +680,9 @@ function iterate()
foreach ($localizedfields as $field => $dummy)
unset($this->$field);
+ foreach ((array)$this->_dyndata as $field => $dummy)
+ unset($this->$field);
+
foreach (($t = $this->_data['dyncols']) ? ($this->_dyndata = (array)json_decode($t, true)) : [] as $field => $value)
$this->_data[$field] = $value;
unset($this->_data['dyncols']);
diff --git a/test/it_dbi.t b/test/it_dbi.t
index 70d7f6f..89df3b8 100755
--- a/test/it_dbi.t
+++ b/test/it_dbi.t
@@ -349,6 +349,17 @@ $r->update(['key4' => "val4'"]); is($r->_writes, 0); is($r-
$r->update(['key4' => "val4'", 'key5' => "val5'"]); is($r->_writes, 1); is($r->key4, "val4'"); is($r->key5, "val5'");
$r->update(['key4' => "val4'", 'key5' => "val5'"]); is($r->_writes, 1); is($r->key4, "val4'"); is($r->key5, "val5'");
+# Check if iterator clears dynfields left over from previous record
+$r->delete(["WHERE 1"]);
+$r->replace(['ID' => 1, 'key1' => "a"]);
+$r->replace(['ID' => 2, 'key2' => "b"]);
+$r->clear(false);
+$r->select("WHERE 1 ORDER BY ID");
+$r->iterate();
+is($r->key1, "a"); is($r->key2, null);
+$r->iterate();
+is($r->key1, null); is($r->key2, "b");
+
#
# Test tracked update
#