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
This commit is contained in:
nate 2008-08-01 04:54:54 +00:00
parent 974e62baf1
commit f5977baeb5

View file

@ -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) {