Queries should not be executed in a view?

0

I just read this now little. "It's important to note that queries should not be executed in a view. The correct thing is that you apply an MVC (Model View Controller) pattern and separate things in. A good example, using Framework Code Igniter "Can someone explain me better, and what is the difference between running the query in the view? And if I should change my project because of this

    
asked by anonymous 16.04.2018 / 19:31

1 answer

0

According to the MVC pattern your queries must be executed by the Model layer. MVC is a very popular standard and widely applied these days. It is a standard and can be replaced by others.

However it is strongly recommended that you follow some pattern, so if someone else maintains your code you will have a little less difficulty understanding it, and even yourself.

In line with MVC it is interesting to follow other good programming practices, such as: DRY , SOLID and others.

Good practices serve to make our code more human-readable, making it easier to maintain and extend the project lifecycle.

The big difference in the place where the query is executed is in the project organization.

As for the issue of changing the project, I believe only you can answer that.

If you are free to start the project again, I recommend you look at Laravel , which is a php framework that applies MVC . I recommend it for the wide community membership and ease of finding material.

    
16.04.2018 / 19:56