Upstream Patch: ORM enhancements for PTA

This commit is contained in:
Deon George 2011-06-25 09:47:06 +10:00
parent 2d7cfd3eb3
commit 338be6719e

View File

@ -705,7 +705,7 @@ class Kohana_ORM extends Model implements serializable {
} }
else 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'])) 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 // 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; $col = ($this->_disable_join_table_name ? '' : $model->_table_name.'.').$fk;
$val = $this->_object[$fk]; $val = $this->_object[$mk];
} }
$model = $model->where($col, '=', $val); $model = $model->where($col, '=', $val);