Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Relations

$
0
0
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

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>