views:

31

answers:

1

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 grab 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?

+2  A: 

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 this: http://book.cakephp.org/view/449/find

quantumSoup
sorry, I see it now, guess I overlooked that in the params, I tend to take the things they list in code as just examples and not actual core documentation so I sometimes overlook it, but I guess I need to look closer... on second thought I guess the cakephp API is the place to consult for things like this as that would list the full params
Rick
@Rick I know how Cake's docs are confusing. Often times I see myself looking at the actual code (ie: ./cake/cake) to understand what's going on.
quantumSoup