使用Laravel Eloquent
Question:
How can we limit the results with Eloquent?
Answer:
In older versions of Laravel, you can use a combination of the take() and skip() methods to emulate the SQL LIMIT clause:
Game::take(30)->skip(30)->get();take() will retrieve the specified number of records, while skip() will offset the results by the given number.
In recent versions of Laravel, a dedicated limit() method is available, along with an OFFSET()方法:
通過使用這些方法,您可以輕鬆地控制雄辯的查詢返回的結果數,從而使您可以通過大型數據集有效地通過大型數據集進行了效率。免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3