public function prevnext($table,$id,$where=[]){
$ids=db($table)->field('id,title')->order('sort asc')->where($where)->column('id'); $key=array_search($id,$ids); // 上一条 if(isset($ids[$key-1])){ $prevnext['prev']=db($table)->field('id,title,country_id')->where('id',$ids[$key-1])->find(); }else{ $prevnext['prev']=false; } if(isset($ids[$key+1])){ $prevnext['next']=db($table)->field('id,title,country_id')->where('id',$ids[$key+1])->find(); }else{ $prevnext['next']=false; } return $prevnext; }