From c15f7de164e4346ec24daf56f4d2acbe1a3dba99 Mon Sep 17 00:00:00 2001 From: Ber Clausen Date: Sat, 21 Dec 2013 11:34:40 -0300 Subject: [PATCH] Re-expose DboSource::fetchAssociated() for BC. Internally use protected methods to fetch hasMany and hasAndBelongsToMany associations. --- lib/Cake/Model/Datasource/DboSource.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index a50aeb39e..3f4df483c 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -1248,7 +1248,7 @@ class DboSource extends DataSource { // Fetch $assocResultSet = array(); if (!empty($assocIds)) { - $assocResultSet = $this->fetchHasMany($Model, $queryTemplate, $assocIds); + $assocResultSet = $this->_fetchHasMany($Model, $queryTemplate, $assocIds); } // Recursively query associations @@ -1286,7 +1286,7 @@ class DboSource extends DataSource { // Fetch $assocResultSet = array(); if (!empty($assocIds)) { - $assocResultSet = $this->fetchHasAndBelongsToMany($Model, $queryTemplate, $assocIds, $association); + $assocResultSet = $this->_fetchHasAndBelongsToMany($Model, $queryTemplate, $assocIds, $association); } $habtmAssocData = $Model->hasAndBelongsToMany[$association]; @@ -1379,6 +1379,21 @@ class DboSource extends DataSource { } } +/** + * Fetch 'hasMany' associations. + * + * This is just a proxy to maintain BC. + * + * @param Model $Model Primary model object. + * @param string $query Association query template. + * @param array $ids Array of IDs of associated records. + * @return array Association results. + * @see DboSource::_fetchHasMany() + */ + public function fetchAssociated(Model $Model, $query, $ids) { + return $this->_fetchHasMany($Model, $query, $ids); + } + /** * Fetch 'hasMany' associations. * @@ -1387,7 +1402,7 @@ class DboSource extends DataSource { * @param array $ids Array of IDs of associated records. * @return array Association results. */ - public function fetchHasMany(Model $Model, $query, $ids) { + protected function _fetchHasMany(Model $Model, $query, $ids) { $ids = array_unique($ids); $query = str_replace('{$__cakeID__$}', implode(', ', $ids), $query); @@ -1407,7 +1422,7 @@ class DboSource extends DataSource { * @param string $association Association name. * @return array Association results. */ - public function fetchHasAndBelongsToMany(Model $Model, $query, $ids, $association) { + protected function _fetchHasAndBelongsToMany(Model $Model, $query, $ids, $association) { $ids = array_unique($ids); if (count($ids) > 1) {