From f5977baeb53733fed2fb055df7158298439b7275 Mon Sep 17 00:00:00 2001 From: nate Date: Fri, 1 Aug 2008 04:54:54 +0000 Subject: [PATCH] Fixing magic find methods in DboSource, and fixing DboSource::reconnect() to merge old params instead of overwriting git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7405 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/model/datasources/dbo_source.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 220a76a7a..60dd37b51 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -120,9 +120,7 @@ class DboSource extends DataSource { */ function reconnect($config = null) { $this->disconnect(); - if ($config != null) { - $this->config = array_merge($this->_baseConfig, $config); - } + $this->setConfig($config); return $this->connect(); } /** @@ -253,18 +251,18 @@ class DboSource extends DataSource { } $c = 0; - $query = array(); + $conditions = array(); + foreach ($field as $f) { - $query[$args[2]->alias . '.' . $f] = $params[$c]; + $conditions[$args[2]->alias . '.' . $f] = $params[$c]; $c++; } if ($or) { - $query = array('OR' => $query); + $conditions = array('OR' => $conditions); } if ($all) { - if (isset($params[3 + $off])) { $limit = $params[3 + $off]; } @@ -276,12 +274,12 @@ class DboSource extends DataSource { if (isset($params[5 + $off])) { $recursive = $params[5 + $off]; } - return $args[2]->findAll($query, $fields, $order, $limit, $page, $recursive); + return $args[2]->find('all', compact('conditions', 'fields', 'order', 'limit', 'page', 'recursive')); } else { if (isset($params[3 + $off])) { $recursive = $params[3 + $off]; } - return $args[2]->find($query, $fields, $order, $recursive); + return $args[2]->find('first', compact('conditions', 'fields', 'order', 'recursive')); } } else { if (isset($args[1]) && $args[1] === true) {