开发者

What do you have in your Model class?

开发者 https://www.devze.com 2022-12-13 00:57 出处:网络
What do you have in your model classes. Generally if i use any framework or any library (Zend Framework) , my classes only have variable which is table name . I know that in complicated applications m

What do you have in your model classes. Generally if i use any framework or any library (Zend Framework) , my classes only have variable which is table name . I know that in complicated applications models have lots of thing to do , so i want to know what these jobs are.

Maybe instead of using library`s general select function ,you create special functions to get data from database ( getUserById() ) . To sum up , which parts of the process should go in to model layer.

For example thing about general user processes .So in registration process where should we check email is acceptable or not . This is example just explain what do you do in your model layer.

This question may seem as an abstract question because of my english 开发者_运维知识库, but it is not . If you can edit it please improve it . The purpose of this question is better understanding of mvc pattern


Well, in general, models should do the main work regarding your business layer. So, if you have a pretty complex query using (and combining) the accessor functions of the database layer (thus, your model), you should instead write an extra function for that query in your model class. Makes it much easier to change the implementation of your model (e.g. database-table-wise).

EDIT: To answer your other question: validating an e-mail should happen in the controller, usually using some kind of component, utility class or library...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号