A
A
Alexey2017-10-13 19:42:25
PHP
Alexey, 2017-10-13 19:42:25

Do I need to separate add and output classes?

Hello!
Once I was told that each entity should have its own class (as far as I understood one) ...
It turns out that one class should be used to add and remove a user from the database, or should they be split somehow?
Say, when getting a user, as far as I understand, I need to make sure that the user model always returns the same object (User) to me.
But if we create a user, then the properties of the class may not match those that were at the output ...
Please explain ... I can not understand the structure ....

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan, 2017-10-13
@LiguidCool

You have a class "User".
As a rule, 1 class is 1 database table, task, etc.
A class has properties and methods. For example: add, remove, get a list.

But if we create a user, then the properties of the class may not match those that were at the output ...
Please explain ... I can not understand the structure ....

After that you have to do save . Typically, this is an ORM task.
Those. you create an ORM:User object, make a request ( pull ) and get data by user (for example, by id ), change something, save ( push ).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question