How does TP5.1 query the previous and next records in the database?

as the title: according to the specified ID number, query the previous record and the next record in the database respectively, and then return the ID number of this record. Please tell a small demo thank you.

Mar.28,2021

->where("id", ">", $id)->order("id", "asc")->find();
->where("id", "<", $id)->order("id", "desc")->find();
Menu