I think the simplest way to see this in action is using BAKE and analizing the generated code.
Please, see the blog tutorial and then, make your own tests using bake. You'll see how cake manage this relations automagically. Regards, Alejandro Gómez Fernández Enviado desde mi iPad El 14/05/2012, a las 17:24, Andrés Manikis <[email protected]> escribió: > Hello. > Is there a way to get a related model when I'm in a controller? > What I mean is doing something like this: > > Suppose I have an Author model and a Book model and an author has many books. > I would like to do something like this: > > class BookController { > public function view($id) { > $book = $this->Book->findById($id); > $author = $book->getAuthor(); > } > } > > I can't find a way to do this. I know other frameworks which can do it like > Rails or Propel and it seems strange Cake can't do it. > For example, in Rails I can do > > book = author.find(params[:id]) > author = book.author > > Thank you very much in advance! > Andrés > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > [email protected] For more options, visit this group at > http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
