@@ -431,7 +431,7 @@ public function getRowResult($query, $last = false)
431431 * @param integer|string $optionalValue (Optional)
432432 * @param string $orderBy (Optional)
433433 *
434- * @return object database results
434+ * @return array| object database results
435435 */
436436 public function get ($ idOrRow = null , $ optionalValue = null , $ orderBy = null )
437437 {
@@ -1496,6 +1496,50 @@ public function orderBy($orderby, $direction = '')
14961496 return $ this ;
14971497 }
14981498
1499+ /**
1500+ * Retrieve previous record in
1501+ * a given table
1502+ *
1503+ * @param int $currentId
1504+ * @param string $fields
1505+ * @return array|object
1506+ */
1507+ public function previous ($ currentId , $ fields = '* ' )
1508+ {
1509+ $ this ->db ->select ($ fields )
1510+ ->from ($ this ->table )
1511+ ->where ('id < ' , $ currentId )
1512+ ->order_by ('id ' , 'desc ' )
1513+ ->limit (1 );
1514+
1515+ $ query = $ this ->db ->get ();
1516+
1517+ return $ this ->getRowResult ($ query );
1518+
1519+ }
1520+
1521+ /**
1522+ * Retrieve next record in
1523+ * a given table
1524+ *
1525+ * @param int $currentId
1526+ * @param string $fields
1527+ * @return array|object
1528+ */
1529+ public function next ($ currentId , $ fields = '* ' )
1530+ {
1531+ $ this ->db ->select ($ fields )
1532+ ->from ($ this ->table )
1533+ ->where ('id > ' , $ currentId )
1534+ ->order_by ('id ' , 'asc ' )
1535+ ->limit (1 );
1536+
1537+ $ query = $ this ->db ->get ();
1538+
1539+ return $ this ->getRowResult ($ query );
1540+
1541+ }
1542+
14991543 /**
15001544 * latest function
15011545 *
0 commit comments