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();
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea3bf1-47a56.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea3bf1-47a56.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?