Fix notice errors with postgres.

This commit is contained in:
mark_story 2012-04-07 17:22:27 -04:00
parent 15c94dee4d
commit 8d1b5c3f24

View file

@ -2874,7 +2874,7 @@ class Model extends Object implements CakeEventListener {
$return = array(); $return = array();
if (isset($results[0])) { if (isset($results[0])) {
$prevVal = Hash::get($results[0], $field); $prevVal = Hash::get($results[0], $field);
$query['conditions'][$field . ' >='] = $prevVal[0]; $query['conditions'][$field . ' >='] = $prevVal;
$query['conditions'][$field . ' !='] = $value; $query['conditions'][$field . ' !='] = $value;
$query['limit'] = 2; $query['limit'] = 2;
} else { } else {
@ -2883,14 +2883,14 @@ class Model extends Object implements CakeEventListener {
$query['limit'] = 1; $query['limit'] = 1;
} }
$query['order'] = $field . ' ASC'; $query['order'] = $field . ' ASC';
$return2 = $this->find('all', $query); $neighbors = $this->find('all', $query);
if (!array_key_exists('prev', $return)) { if (!array_key_exists('prev', $return)) {
$return['prev'] = $return2[0]; $return['prev'] = $neighbors[0];
} }
if (count($return2) === 2) { if (count($neighbors) === 2) {
$return['next'] = $return2[1]; $return['next'] = $neighbors[1];
} elseif (count($return2) === 1 && !$return['prev']) { } elseif (count($neighbors) === 1 && !$return['prev']) {
$return['next'] = $return2[0]; $return['next'] = $neighbors[0];
} else { } else {
$return['next'] = null; $return['next'] = null;
} }