public function findPrevInOrder($ordering, array $where = array(), $entity_name = null, $primary_key_field = null) { try { $predicate = new \Zend\Db\Sql\Where(); $where[] = $predicate->greaterThan('entity_ordering', $ordering); $select = $this->getFetchSelect($where, array('ordering ' . ($this->ordering == 'DESC' ? 'ASC' : 'DESC')), array(), null, $entity_name, $primary_key_field); $select->limit(1); $entity = $this->select($select)->current(); if ($entity) { return $entity; } return false; } catch (\Exception $e) { echo $e->getMessage(); return false; } }