diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index 7bc700c7e..c23ce9b03 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -527,7 +527,7 @@ class DataSource extends Object { } break; case '{$__cakeForeignKey__$}': - foreach ($model->__associations as $id => $name) { + foreach ($model->associations() as $id => $name) { foreach ($model->$name as $assocName => $assoc) { if ($assocName === $association) { if (isset($assoc['foreignKey'])) { diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/cake/libs/model/datasources/dbo/dbo_oracle.php index 063dc4764..3734e4e43 100644 --- a/cake/libs/model/datasources/dbo/dbo_oracle.php +++ b/cake/libs/model/datasources/dbo/dbo_oracle.php @@ -1026,7 +1026,7 @@ class DboOracle extends DboSource { if (!empty($fetch) && is_array($fetch)) { if ($recursive > 0) { - foreach ($linkModel->__associations as $type1) { + foreach ($linkModel->associations() as $type1) { foreach ($linkModel->{$type1} as $assoc1 => $assocData1) { $deepModel =& $linkModel->{$assoc1}; $tmpStack = $stack; @@ -1088,7 +1088,7 @@ class DboOracle extends DboSource { if (!empty($fetch) && is_array($fetch)) { if ($recursive > 0) { - foreach ($linkModel->__associations as $type1) { + foreach ($linkModel->associations() as $type1) { foreach ($linkModel->{$type1} as $assoc1 => $assocData1) { $deepModel =& $linkModel->{$assoc1}; diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 55416c63c..e2a845f72 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -779,7 +779,7 @@ class DboSource extends DataSource { $queryData['fields'] = $this->fields($model); } - $_associations = $model->__associations; + $_associations = $model->associations(); if ($model->recursive == -1) { $_associations = array(); @@ -922,7 +922,7 @@ class DboSource extends DataSource { if (!empty($fetch) && is_array($fetch)) { if ($recursive > 0) { - foreach ($linkModel->__associations as $type1) { + foreach ($linkModel->associations() as $type1) { foreach ($linkModel->{$type1} as $assoc1 => $assocData1) { $deepModel =& $linkModel->{$assoc1}; $tmpStack = $stack; @@ -991,7 +991,7 @@ class DboSource extends DataSource { if (!empty($fetch) && is_array($fetch)) { if ($recursive > 0) { - foreach ($linkModel->__associations as $type1) { + foreach ($linkModel->associations() as $type1) { foreach ($linkModel->{$type1} as $assoc1 => $assocData1) { $deepModel =& $linkModel->{$assoc1}; diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index ab26e8dae..59035bcb6 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -2814,6 +2814,16 @@ class Model extends Overloadable { return $db; } +/** + * Get associations + * + * @return array + * @access public + */ + function associations() { + return $this->__associations; + } + /** * Gets all the models with which this model is associated. * diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index bee5967a5..c87476e12 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -1400,7 +1400,7 @@ class DboSourceTest extends CakeTestCase { $queryData = array(); - foreach ($this->Model->Category2->__associations as $type) { + foreach ($this->Model->Category2->associations() as $type) { foreach ($this->Model->Category2->{$type} as $assoc => $assocData) { $linkModel =& $this->Model->Category2->{$assoc}; $external = isset($assocData['external']); @@ -2185,7 +2185,7 @@ class DboSourceTest extends CakeTestCase { * @return void */ function _buildRelatedModels(&$model) { - foreach ($model->__associations as $type) { + foreach ($model->associations() as $type) { foreach ($model->{$type} as $assoc => $assocData) { if (is_string($assocData)) { $className = $assocData;