From 8d4bd65f9d80902a8c82126648011e145f686cc1 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Wed, 13 Apr 2011 15:35:19 +0000 Subject: Fix iteration over localized fields, added test for it --- it_dbi.class | 6 +++++- tests/it_dbi.t | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/it_dbi.class b/it_dbi.class index b02960d..a8503d3 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -590,10 +590,14 @@ function iterate() { if ($this->_data = mysql_fetch_assoc($this->_result)) { + if ($localizedfields = $this->_localizedfields) + foreach ($localizedfields as $field => $dummy) + unset($this->$field); + foreach ($this->_data as $field => $value) $this->$field = isset($value) && $this->_isint[$field] ? ($this->_data[$field] = intval($value)) : $value; - if ($localizedfields = $this->_localizedfields) + if ($localizedfields) { $lang = T_lang(); foreach ($localizedfields as $field => $dummy) diff --git a/tests/it_dbi.t b/tests/it_dbi.t index c885930..4a58188 100755 --- a/tests/it_dbi.t +++ b/tests/it_dbi.t @@ -227,14 +227,22 @@ $dbi->query('create temporary table it_dbi_testlocalized ( $record = new it_dbi($db + array('table' => "it_dbi_testlocalized")); $record->insert(array('foobar_de' => "deutsch", 'foobar_fr' => "franz")); +$record->insert(array('foobar_de' => "deutsch2", 'foobar_fr' => "franz2")); T_set_language('de'); -$record->read(1); +$record->select(array()); +$record->iterate(); is( array($record->_key, $record->foobar), array(1, "deutsch"), "localized field foobar_de" ); +$record->iterate(); +is( + array($record->_key, $record->foobar), + array(2, "deutsch2"), + "localized field foobar_de iterate" +); T_set_language('fr'); $record->read(1); -- cgit v1.2.3