Should searching be done in the view?
Should searching be done explicitly in the view, or done in the controller and results passed to the view?
My guess is the view, to keep controllers skinny. If so, should the controller pass the search parameters to the view, or can the view get those themselves through $_POST, $_GET variables? My take on it is that the controller is responsible for delegation (routing) and handling requests, so I would think that it should pass the view whatever data it needs to do its job (same for the 开发者_高级运维model). Is this correct?
Thanks
You're right that the controllers should be kept skinny, but the corollary to that is to have fat models; here, you should pass the search parameters to your model.
The controller can deal with the $_REQUEST
parameters but should translate them into something generic for the model class to deal with. It can then return you a collection of models which match the search parameters, and your controller can set that collection onto the view.
精彩评论