Because for example if your two table had 2 same column (for ex. ‘id’),
value of attribute ‘id’ of model and his relationed model
would not be identified exacty.
So if you need to have attributes of relationed model then you should use relations with hasOne or hasMany. But if you need only to filter model’s record against an other table, you can use innerJoin() or leftJoin() of ActiveRecord class.
My relationship table would only consist of two ID columns which would "key together" my relations. So my "relationshipTable" table would look like this:
Let’s say my relationshipTable holds “orders” and my user have hundreds of orders. I don’t want those orders to be fetched with an “IN()” statement and hundreds of ID’s specified in the SQL. This “hasMany” relationship would be much better with one SQL-statement using a JOIN.
Am I using the relationship part of the ActiveRecord in a wrong way maybe?
Ah okay. I think I’ll switch my code to see what that does to my relations. Right now I’m just accessing my relation in question on my record like to $record->relationships();. I’ll try it your way. Cheers!