PHP MVC correct usage
Posted
by Ratt
on Stack Overflow
See other posts from Stack Overflow
or by Ratt
Published on 2010-05-26T08:33:07Z
Indexed on
2010/05/26
8:41 UTC
Read the original article
Hit count: 278
What is the correct (recommended method) for passing information to a view in a MVC environment.
Currently we use Zend Framework, where we write classes to handle specific things EG
a Book class with a save and load method to retrieve info from the DB, which is called from a particular nameAction().
What I would like to know is what is the best way to pass this information to the view, in some cases we do $this->view->book_name = $book->getBookName();
and in other cases we do the following
$this->view->book = $book; OR $this->view->books = Book_Manager::getAllBooks(); and then access the object(s) properties in the view.
Information on-line suggests we try limit what access a view has to information, i.e pass them only what they need and in some cases people say its ok to pass stuff through as long as nothing is done to that information.
Regards
© Stack Overflow or respective owner