I have a problem, I have a database with two tables should be related, but they are not and have no way to create that relationship.
one of the tables has a field that could be related to the key field in the other table.
I tried to use the functions of relationship that brings models yii2 default, but does nothing and do not know if I need to do something else to create the relationship through models only.
I found the problem… it is the type field, one is char and another is varchar. I cloned the DB to check it and when i changed type field i could access the other model.
Yes I can’t establish any foreign key constraint on DB level.
I’ve never tried such a relation relying on char and/or varchar fields, but by manually defining a relation you could achieve some sort of relational functionality with it. For instance, lazy loading of a related model, eager loading of the relation using “with” may work, because they only use “where” clause. But other features using table joining may not work.