K
K
Kekoc2016-07-12 15:34:29
MySQL
Kekoc, 2016-07-12 15:34:29

How to make one link to two Yii2 models?

Hello.
There is a model, it has a field, but it is not known which model will be used by the user.
Those. there are two tables with identical data, but they cannot be merged. The codes are the same in both.
The user creates a model and selects certain data to fill in from different models. How to make the most optimal way so that one field can refer to different tables.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2016-07-12
@ThunderCat

There is a model, she has a field,

field for what?
what codes?
If the data is identical - then what's the point of keeping them in different tables. If the "codes are the same" and everything else is the same - is it possible that they are the same thing? Or indistinguishable one from the other. The conclusion is to add a unique index, combine tables and learn how to correctly formulate questions. If the solution does not fit, then only the last point.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question