I currently have a problem with a relation of a table, I believe it’s because the relation is using a different column then the one I want to use, for example:
I have:
TABLE A
idA
xxxID
yyyID
name
TABLE B
idB
xxxID
What is happening is that I want to get the A.name by joining A.xxxID and B.xxxID, now if I create the relation:
it’s joining the tables by A.xxxId and B.idB, giving me values that don’t have anything to do with what I want, is there a way in the relation array to say which fields I want to use in the join?
I’ve checked the page Relations, but I don’t see a way to go around this. Is my only option to use the criteria to manipulate de Join?
Yes, but the indexs have different names in each table, does it make a diference?
Also right now I’m changing the table B so the primary key is actually the foreign key, since it works in other places, I don’t believe it will have any impact on the remainig project, but I’ll check it out.
The problem has been solved simply by changing the self::HAS_ONE to self::BELONGS_TO, not really sure why in this case but right now everything seems to be working ok.
Hello, your situation is very similar to mine, using your example I had to create a foreign key from TableB.field to TableA.field, and then on the TableB model on the relations declaration, I used something like: