如何在CakePHP中将find限制为特定的数字? [英] How can I limit the find to a specific number in CakePHP?

查看:122
本文介绍了如何在CakePHP中将find限制为特定的数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户模型,给我最新的用户作为输出。

I have a user model which gives me latest users as output. How can I limit the record to just output me 200 records instead of all the users in database?

推荐答案

根据文档的第二个参数, find()方法是一个 $ params 数组。

According to the documentation, the second argument to the find() method is a $params array.

在此数组中传递的可能值之一是 limit 键。因此,您可以执行以下操作:

One of the possible values to pass in this array is a limit key. So you could do the following:

$users = $this->User->find('all', array('limit' => 200));

这篇关于如何在CakePHP中将find限制为特定的数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆