Answer the question
In order to leave comments, you need to log in
How to implement a set of heterogeneous properties for an element?
Let's say there is a table in the database with elements. Each element has properties, they can be of different types (string, number, boolean, plural or list). How can I implement the binding of properties to an element so that it would be convenient to pull them out of the database? Preferably under PHP, ideally under Yii2.
If there are any ready-made solutions, please point a finger or point me on the right path.
Answer the question
In order to leave comments, you need to log in
If we talk about the data structure, then everything is solved quite simply.
1) entity table (obviously you have it).
2) a table of properties (indicating the type of properties, whether it has standard values or individual values for each entity.
3) a table of property values (entity id ,property id, value). The third table may have some other data, such as the date of setting, the author of the changes, and so on.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question