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

Signed-off-by: mark_story <mark@mark-story.com>
This commit is contained in:
Juan Basso 2010-04-18 22:22:09 -03:00 committed by mark_story
parent 7d51952801
commit 2d44929598

View file

@ -924,6 +924,7 @@ class DboSource extends DataSource {
}
if (!empty($ins)) {
$ins = array_unique($ins);
$fetch = $this->fetchAssociated($model, $query, $ins);
}
@ -955,10 +956,10 @@ class DboSource extends DataSource {
}
}
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 @@ class DboSource extends DataSource {
$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 @@ class DboSource extends DataSource {
}
} 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) . ' = (';