(1) Schedule has a user_id and schedule_type_id. (2) Schedule has a $_belongs_to property (It contains user and schedule_type relation). (3) Both user and schedule type Models are not have any relation property with schedule. (4) Get columns "schedule.*", "schedule_type.name" and "user.name" To show View. (5) All tables have "entry_time" column.
---------------- <Trouble> ---------------- (1) Results contain "_data_relations" automatically. But it's not all relations. "schedule_type" is contained, but "user" is not. Why did not user contain?
(2) I think there is some possiblity what MySql not returns user column. So I changed select method like:
select('*')
Then 'schedule.entry_time' is overrited by other table's same column data. I add column to "select()" method like:
I dumped the SQL by DB::last_query method contains join queried. Why result which is not accessed by it's property don't contain relation datas? Where are they saved?
If you feed data into a Model object, you're supposed to do the hydration yourself, the ORM model does not contain the logic to disect the result of a join, and automatically create related object, it does not know how to split the records.
This is why ORM queries use aliases, so the field prefix in the result can be used to map the field back to the table, and because the ORM knows which relations you have included, in knows which related model objects it has to instantiate.
It does not have any knowledge of related table names.