diff --git a/includes/kohana/modules/orm/classes/kohana/orm.php b/includes/kohana/modules/orm/classes/kohana/orm.php index ace966a..be9a2e8 100644 --- a/includes/kohana/modules/orm/classes/kohana/orm.php +++ b/includes/kohana/modules/orm/classes/kohana/orm.php @@ -705,7 +705,7 @@ class Kohana_ORM extends Model implements serializable { } else { - foreach ($this->_has_many[$column]['foreign_key'] as $fk) + foreach ($this->_has_many[$column]['foreign_key'] as $mk => $fk) { if (isset($this->_has_many[$column]['through'])) { @@ -715,7 +715,7 @@ class Kohana_ORM extends Model implements serializable { { // Simple has_many relationship, search where target model's foreign key is this model's primary key $col = ($this->_disable_join_table_name ? '' : $model->_table_name.'.').$fk; - $val = $this->_object[$fk]; + $val = $this->_object[$mk]; } $model = $model->where($col, '=', $val);