K
K
Kirill Batalin2014-08-12 18:07:02
Yii
Kirill Batalin, 2014-08-12 18:07:02

Yii: One large or several small models?

Hello
Tell me, is it better to make one large User model (authorization, registration, confirmation, password recovery) or divide it into several small ones?
The question arose because www.yiiframework.com/doc/guide/1.1/en/form.model is separated (LoginForm is separated from User, although it was possible to write everything in User and use scripts), and on some other resources (for example , www.dbhelp.ru/yii-auth-and-reg-2/page/) all shove into one model

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2014-08-12
Protko @Fesor

LoginForm is LoginForm and User is User. LoginForm may not intersect with User at all (suddenly). Basically, whatever you want. It's Yii...

T
terehinis, 2014-08-13
@terehinis

It all depends on how large-scale functionality the models will have. For example, if you make two models, and in the Users model there will be no functionality other than the functionality generated through gii (well, +2 functions for example), then there is no point in dividing it, you will only lose speed. If the Users model contains a bunch of complex handlers (interaction with other databases, programmatic data control, etc.), then it’s easier to separate for visual convenience. It all depends on the complexity of the task.
PS In most cases, such functionality is combined

S
Svetlana Okuneva, 2014-08-22
@Rheola

The problem is solved by specifying scenarios - registration, authorization, and so on, and the corresponding set of validation rules for each scenario.
My personal opinion is that there are not so many of them there to be spread over several models.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question