Author: phpnut
Date: 4:32:45 PM, Saturday, October 22, 2005
Message:
Adding fixed for Ticket #91




git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1162 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2005-10-22 21:34:17 +00:00
parent 2bb31637cf
commit 9f411d1be4

View file

@ -1331,13 +1331,15 @@ class Model extends Object
* @param unknown_type $value * @param unknown_type $value
* @return array Array with keys "prev" and "next" that holds the id's * @return array Array with keys "prev" and "next" that holds the id's
*/ */
function findNeighbours ($conditions, $field, $value) function findNeighbours ($conditions, $field, $value)
{ {
list($prev) = Model::findAll($conditions." AND {$field} < '{$value}'", $field, "{$field} DESC", 1); @list($prev) = Model::findAll($conditions." AND {$field} < '{$value}'", $field, "{$field} DESC", 1);
list($next) = Model::findAll($conditions." AND {$field} > '{$value}'", $field, "{$field} ASC", 1); @list($next) = Model::findAll($conditions." AND {$field} > '{$value}'", $field, "{$field} ASC", 1);
return array('prev'=>$prev['id'], 'next'=>$next['id']); $prev = isset($prev) ? $prev: false;
} $next = isset($next) ? $next: false;
return array('prev'=>$prev, 'next'=>$next);
}
/** /**
* Returns a resultset for given SQL statement. * Returns a resultset for given SQL statement.