In cakephp what is the method to filter data on a database request.
Do I filter the data from a model or a controller?
Say if I have a table with 1000's of rows and I only want to select rows on a condition , like a where clause on sql.
The user enters in a certain fields to select rows from a table.
I then pass this variable to the controller and the controller filters this data or is the model supposed to filter the rows selected?
I didnt quite see this clearly from the cakephp docs.
I am not sure if a model or controller is the best way to go about it.
-- Do I filter the data from a model or a controller?
Say if I have a table with 1000's of rows and I only want to select rows on a condition , like a where clause on sql.
The user enters in a certain fields to select rows from a table.
I then pass this variable to the controller and the controller filters this data or is the model supposed to filter the rows selected?
I didnt quite see this clearly from the cakephp docs.
I am not sure if a model or controller is the best way to go about it.
a controller would do /// public function view($id = null) { $post = $this->Post->findById($id); $this->set('post', $post); } a model would do something like the below where you set the condition and this seems a really messy way to go about things. class Recipe extends AppModel { public $hasAndBelongsToMany = array( 'Ingredient' => array( 'className' => 'Ingredient', 'joinTable' => 'ingredients_recipes', 'foreignKey' => 'recipe_id', 'associationForeignKey' => 'ingredient_id', 'unique' => true, 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'finderQuery' => '', 'with' => '' ) ); }
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment