I would like to Yii:afi my application with a nice relation.
Today i have this SQL:
SELECT hours,date FROM tbl_day INNER JOIN tbl_user ON tbl_day.userId=tbl_user.id WHERE tbl_user.companyId=".Yii::app()->user->companyId
I have treid to manage this SQL into a relation statment in my Company model but cant figure it out.
Its three tables, Company, Users and Days.
Company has many Users
Users has many Days
I have tried in my company model MANY_MANY and HAS_MANY but cant figure it out, any idees?
I think the problem can be that tbl_day.userId and tbl_user.companyId not is a PK. Only tbl_user.id is a PK.
Thanks