使用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