Skip to main content
add more details
Source Link

A View should be as dumb as possible. It should not access the database. Fetching the data is the responsibility of the Controller.

The controller should use an ORM to fetch the data from the database (preferably using an ORM) and feed it to the appropriate view.

Edit

Let's assume you are writing a web app to manage books. You write a BooksController and you have an action to show the details of a book. Let's assume you call that action show. In the show action, you query the database for the book you want to show the details of (preferably using an ORM). You store it in a variable and pass in that variable to the view to be rendered. How you pass that variable depends on how you have implemented the rendering logic.

Edit 2

As @candied_orange mentioned in the comments, using an ORM is not a requirement to use MVC. But IMHO it is worth using an ORM, because it saves you a lot of headache (albeit introducing some new headaches).

A View should be as dumb as possible. It should not access the database. Fetching the data is the responsibility of the Controller.

The controller should use an ORM to fetch the data from the database and feed it to the appropriate view.

Edit

Let's assume you are writing a web app to manage books. You write a BooksController and you have an action to show the details of a book. Let's assume you call that action show. In the show action, you query the database for the book you want to show the details of (preferably using an ORM). You store it in a variable and pass in that variable to the view to be rendered. How you pass that variable depends on how you have implemented the rendering logic.

A View should be as dumb as possible. It should not access the database. Fetching the data is the responsibility of the Controller.

The controller should fetch the data from the database (preferably using an ORM) and feed it to the appropriate view.

Edit

Let's assume you are writing a web app to manage books. You write a BooksController and you have an action to show the details of a book. Let's assume you call that action show. In the show action, you query the database for the book you want to show the details of (preferably using an ORM). You store it in a variable and pass in that variable to the view to be rendered. How you pass that variable depends on how you have implemented the rendering logic.

Edit 2

As @candied_orange mentioned in the comments, using an ORM is not a requirement to use MVC. But IMHO it is worth using an ORM, because it saves you a lot of headache (albeit introducing some new headaches).

add more details
Source Link

A View should be as dumb as possible. It should not access the database. Fetching the data is the responsibility of the Controller.

The controller should use an ORM to fetch the data from the database and feed it to the appropriate view.

Edit

Let's assume you are writing a web app to manage books. You write a BooksController and you have an action to show the details of a book. Let's assume you call that action show. In the show action, you query the database for the book you want to show the details of (usingpreferably using an ORM). You store it in a variable and pass in that variable to the view to be rendered. How you pass that variable depends on how you have implemented the rendering logic.

A View should be as dumb as possible. It should not access the database. Fetching the data is the responsibility of the Controller.

The controller should use an ORM to fetch the data from the database and feed it to the appropriate view.

Edit

Let's assume you are writing a web app to manage books. You write a BooksController and you have an action to show the details of a book. Let's assume you call that action show. In the show action, you query the database for the book you want to show the details of (using an ORM). You store it in a variable and pass in that variable to the view to be rendered. How you pass that variable depends on how you have implemented the rendering logic.

A View should be as dumb as possible. It should not access the database. Fetching the data is the responsibility of the Controller.

The controller should use an ORM to fetch the data from the database and feed it to the appropriate view.

Edit

Let's assume you are writing a web app to manage books. You write a BooksController and you have an action to show the details of a book. Let's assume you call that action show. In the show action, you query the database for the book you want to show the details of (preferably using an ORM). You store it in a variable and pass in that variable to the view to be rendered. How you pass that variable depends on how you have implemented the rendering logic.

A View should be as dumb as possible. It should not access the database. Fetching the data is the responsibility of the Controller.

The controller should use an ORM to fetch the data from the database and feed it to the appropriate view.

Edit

Let's assume you are writing a web app to manage books. You write a BooksController and you have an action to show the details of a book. Let's assume you call that action show. In the show action, you query the database for the boombook you want to show the details of (using an ORM). You store it in a variable and pass in that variable to the view to be rendered. How you pass that variable depends on how you have implemented the rendering logic.

A View should be as dumb as possible. It should not access the database. Fetching the data is the responsibility of the Controller.

The controller should use an ORM to fetch the data from the database and feed it to the appropriate view.

Edit

Let's assume you are writing a web app to manage books. You write a BooksController and you have an action to show the details of a book. Let's assume you call that action show. In the show action, you query the database for the boom you want to show the details of (using an ORM). You store it in a variable and pass in that variable to the view to be rendered. How you pass that variable depends on how you have implemented the rendering logic.

A View should be as dumb as possible. It should not access the database. Fetching the data is the responsibility of the Controller.

The controller should use an ORM to fetch the data from the database and feed it to the appropriate view.

Edit

Let's assume you are writing a web app to manage books. You write a BooksController and you have an action to show the details of a book. Let's assume you call that action show. In the show action, you query the database for the book you want to show the details of (using an ORM). You store it in a variable and pass in that variable to the view to be rendered. How you pass that variable depends on how you have implemented the rendering logic.

added 468 characters in body
Source Link
Loading
Source Link
Loading