Answer the question
In order to leave comments, you need to log in
How to correctly initialize a class with a large number of fields?
There is an ORM (rather, QueryBuilder), which has a getByID method that returns an array with the fields of one table row from the database.
We need to turn this array into an object that has its own business logic.
Let's take users for example.
The user has about two dozen fields, some of them are required, some are not. In the constructor of the User class, you need to list all these fields and pass them during initialization? And if you need to select not all fields, but only a part?
Please tell me what to read on this topic. Perhaps there are some existing open source solutions to learn from?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question