开发者

Cakephp, retrieve only certain number of rows from database?

I don't know if I'm missing something, or what, but I've been looking over the cakephp cookbook a lot lately and I don't think I have figured a way from it to get "x" number of rows (say 100) based on criteria.. right now I'm just using the find method to get all rows and then using my php controller to make use of only the ones I need, this just seems really inefficient (I don't mean inefficient in terms of writing the php code but as far as system resources, but maybe I'm wrong? Since I suppose mysql has to do some extra work to get just x number of rows, is it just as efficient to gr开发者_JAVA百科ab all the rows and process in php?.. its just on the local server so its not using bandwidth)

Is the only way to do this in cakephp with a custom mysql query?


DON'T retrieve all the rows and process them with PHP unless you absolutely have to. That's why the LIMIT clause exists.

You can specify a lot of parameters for find(), including a limit.

Read Retrieving Your Data > Find

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜