123456789101112131415161718192021222324252627282930 |
- <?php
- namespace app\model;
- class NovelData extends \think\Model
- {
- protected $pk = 'id';
- public static function getNextPrev($id, $nid = null)
- {
- $whereP = [];
- $whereN = [];
- // $whereP[] = ['status', '=', 1];
- // $whereN[] = ['status', '=', 1];
-
- if ($nid) {
- $whereP[] = ['n_id', '=', $nid];
- $whereN[] = ['n_id', '=', $nid];
- }
- $whereP[] = ['id', "<", $id];
- $whereN[] = ['id', ">", $id];
- $data_P = self::where($whereP)->order("id asc")->limit(1)->find();
- $data_N = self::where($whereN)->order("id asc")->limit(1)->find();
- return ['prev' => $data_P, 'next' => $data_N];
- }
- }
|