Fix issue #1591
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
index 94782b2..d44df6c 100644
--- a/system/database/DB_result.php
+++ b/system/database/DB_result.php
@@ -144,7 +144,7 @@
 			{
 				$this->custom_result_object[$class_name][$i] = new $class_name();
 
-				foreach ($this->$_data as $key => $value)
+				foreach ($this->{$_data}[$i] as $key => $value)
 				{
 					$this->custom_result_object[$class_name][$i]->$key = $value;
 				}