First of all people: what Rule? It's not made of rules, it's a pattern to follow - but follow as you want. Second, no, it doesn't "break the Rule" it only makes your code uglier and hard to read - see above - but the thing is, why to use a hand made query when you can easily/prettier/"readablier" use Model built-in methods to accomplish the same?
About performing custom find methods, with default/mandatory/pre- defined params you should read: > > http://rafaelbandeira3.wordpress.com/2008/08/28/the-new-way-to-define-find-methods/ > > http://cakebaker.42dh.com/2008/09/23/an-alternative-way-to-define-custom-find-types/ About the rules: Even being annoying, executing hand made queries on the controller still leaves all the data transaction and structuration on the Model side, and it lets the pattern intended to be followed intact, but it's not the best practice. If even following the links presented - and links cited inside them, you still not find the solution for a more complex and featured query, try to implement it inside a model method to make your controller cleaner: $this->Model->find("where id=xyz") becomes $this->Model->find('axis', array('id' => 'xyz')); // following those links or $this->Model->getByAxis($axis); But in the specific case you presented, you could easily use Model methods overload by calling $this->Model->findById($id), $this->Model- >findBy<FieldName>($fieldValue); Still thinks that executing queries is needed? rafaelbandeira3 http://rafaelbandeira3.wordpress.com > but i heared if you direct query in controller will violate the MVC > rule > > i.e if you use $this->Model->query("select * from models"); > > the above query will violate the MVC rule. > > i heared the queries shouldnotbe written in controller it should be > inmodeli.e in urmodel.php > > even i am alsonotabsolute on this part > > On Sep 23, 2:33 pm, forrestgump <[EMAIL PROTECTED]> wrote: > > > Hey guys, > > Considering the fact that CakePhp follows the MVC architecture, id > > like to know...y we dont make function calls such as $this->find("where > > id=xyz") from function blocks typed out in Models rather > > > than controllers....im sure there is a logical reason to it...but > > someone asked me this question and i couldnotgive her a good enuf > > answer....does making function calls to queries like find(), save() > > work better in models or controllers?.....and is it good practice to > > pass conditions in your function call while using it in a controller? > > eg find("where id=1") ; > > > Does using $this->find() in controller violate the MVC architecture in > > any manner? > > > Can someone please clarify these question for us? > > > Thanks in advance, > > forrestgump --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---