Permalink
Browse files

Optimization on dbo datasource to not repeat ids in find. Fixes #601

Signed-off-by: mark_story <mark@mark-story.com>
  • Loading branch information...
1 parent 7d51952 commit 2d449295981fbcceb9217a82e680383e0ee41c02 @jrbasso jrbasso committed with markstory Apr 19, 2010
Showing with 3 additions and 3 deletions.
  1. +3 −3 cake/libs/model/datasources/dbo_source.php
View
6 cake/libs/model/datasources/dbo_source.php
@@ -924,6 +924,7 @@ function queryAssociation(&$model, &$linkModel, $type, $association, $assocData,
}
if (!empty($ins)) {
+ $ins = array_unique($ins);
$fetch = $this->fetchAssociated($model, $query, $ins);
}
@@ -955,10 +956,10 @@ function queryAssociation(&$model, &$linkModel, $type, $association, $assocData,
}
}
if (!empty($ins)) {
+ $ins = array_unique($ins);
if (count($ins) > 1) {
$query = str_replace('{$__cakeID__$}', '(' .implode(', ', $ins) .')', $query);
$query = str_replace('= (', 'IN (', $query);
- $query = str_replace('= (', 'IN (', $query);
} else {
$query = str_replace('{$__cakeID__$}',$ins[0], $query);
}
@@ -1060,7 +1061,6 @@ function fetchAssociated($model, $query, $ids) {
$query = str_replace('{$__cakeID__$}', implode(', ', $ids), $query);
if (count($ids) > 1) {
$query = str_replace('= (', 'IN (', $query);
- $query = str_replace('= (', 'IN (', $query);
}
return $this->fetchAll($query, $model->cacheQueries, $model->alias);
}
@@ -2179,7 +2179,7 @@ function conditionKeysToString($conditions, $quoteValues = true, $model = null)
}
} elseif (is_array($value) && !empty($value) && !$valueInsert) {
$keys = array_keys($value);
- if (array_keys($value) === array_values(array_keys($value))) {
+ if ($keys === array_values($keys)) {
$count = count($value);
if ($count === 1) {
$data = $this->__quoteFields($key) . ' = (';

0 comments on commit 2d44929

Please sign in to comment.