Adding fix for Ticket #2317.

Added ability to cache queries to Model::query() by passing true as a second param.
Before this method would turn off caching automatically and there was no way to turn it on.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4784 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-04-05 16:50:03 +00:00
parent b486b6f076
commit 56451426fb
2 changed files with 5 additions and 2 deletions

View file

@ -86,7 +86,7 @@ class AclNode extends AppModel {
$query .= "ON {$type}{$k}.lft > {$type}{$i}.lft && {$type}{$k}.rght < {$type}{$i}.rght "; $query .= "ON {$type}{$k}.lft > {$type}{$i}.lft && {$type}{$k}.rght < {$type}{$i}.rght ";
$query .= "AND {$type}{$k}.alias = " . $db->value($alias) . " "; $query .= "AND {$type}{$k}.alias = " . $db->value($alias) . " ";
} }
$result = $this->query("{$query} WHERE {$type}.lft <= {$type}0.lft AND {$type}.rght >= {$type}0.rght ORDER BY {$type}.lft DESC"); $result = $this->query("{$query} WHERE {$type}.lft <= {$type}0.lft AND {$type}.rght >= {$type}0.rght ORDER BY {$type}.lft DESC", $this->cacheQueries);
} elseif (is_object($ref) && is_a($ref, 'Model')) { } elseif (is_object($ref) && is_a($ref, 'Model')) {
$ref = array('model' => $ref->name, 'foreign_key' => $ref->id); $ref = array('model' => $ref->name, 'foreign_key' => $ref->id);
} elseif (is_array($ref) && !(isset($ref['model']) && isset($ref['foreign_key']))) { } elseif (is_array($ref) && !(isset($ref['model']) && isset($ref['foreign_key']))) {
@ -123,7 +123,7 @@ class AclNode extends AppModel {
$query = "SELECT {$type}.* From {$prefix}{$table} AS {$type} "; $query = "SELECT {$type}.* From {$prefix}{$table} AS {$type} ";
$query .= "LEFT JOIN {$prefix}{$table} AS {$type}0 "; $query .= "LEFT JOIN {$prefix}{$table} AS {$type}0 ";
$query .= "ON {$type}.lft <= {$type}0.lft AND {$type}.rght >= {$type}0.rght "; $query .= "ON {$type}.lft <= {$type}0.lft AND {$type}.rght >= {$type}0.rght ";
$result = $this->query("{$query} " . $db->conditions($ref) ." ORDER BY {$type}.lft DESC"); $result = $this->query("{$query} " . $db->conditions($ref) ." ORDER BY {$type}.lft DESC", $this->cacheQueries);
if (!$result) { if (!$result) {
pr($this->trace()); pr($this->trace());

View file

@ -246,6 +246,9 @@ class DboSource extends DataSource {
return $args[2]->find($query, $fields, $order, $recursive); return $args[2]->find($query, $fields, $order, $recursive);
} }
} else { } else {
if(isset($args[1]) && $args[1] === true){
return $this->fetchAll($args[0], true);
}
return $this->fetchAll($args[0], false); return $this->fetchAll($args[0], false);
} }
} }