Trying to understand MVC models, tips?

I am writing my own MVC to learn this. I have almost everything that is down-stroked, and my main material, written in addition to models due to some problems that understand them and the lack of viable examples.

Now they told me that the model should appear in front of one line, someone told me that your model class should update / insert and delete lines, anything that involves the selection of one or more lines - the class "finder" should.

So ... a) what is the finder class, b) how to implement it in the use case, c) Is what I was told about the models correct or is there a better way than the "crawlers"?

The tip is very convenient :)

+3
source share
4 answers

It is a common misconception that M in MVC is just a database. The main goal of MVC is to separate the presentation layer from the remaining application so that M does not know about VC.

V and C form the UI, the outer layer with which users can interact with your application. C processes all input requests from V and delegates them to M, where necessary. V displays changes in M. In webbased MVC, V is further divided by content, presentation, and behavior, for example. HTML, CSS and JavaScript.

M. . , , , . , DAL, , .. - , , RSS- Web- ..

DAL , - . . : , , .

http://martinfowler.com/eaaCatalog/index.html .

+6

- " ".

( , ). -. , , .

Doctrine, Doctrine 2 doctrine.

, MVC, Zend Framework, Zend_Model. .

0

CakePHP :

CakePHP . , -, , , LDAP, iCal CSV.

(http://book.cakephp.org/view/66/Models)

, -. .

, "- ", PHP.

, . ​​ : - Doctrine db - .

- , - . - "Collection", , .

: , , "" "" , . , "SELECT FROM table WHERE id = x". .

-1
source

You can implement finders as static methods of a model class:

$foo = ModelFoo::find($id)

-2
source

Source: https://habr.com/ru/post/1744085/


All Articles