How to convert mysql query to yii.?
I have 3 table
- user_header
- customers
- customer_ratings
and this is my sql query
SELECT t.email
FROM otz_user_header t
JOIN otz_customers r
ON t.user_id = r.customer_user_id
JOIN otz_customer_ratings cr
ON cr.customer_user_id = r.customer_user_id
WHERE r.rate_auto_approve = 0
AND r.rate_email_time IS NOT NULL
AND r.total_rating_count IS NOT NULL
AND cr.rating_date < Curdate()
AND cr.rating_date > Date_sub(Curdate(), INTERVAL 7 day)
How to convert this query to yii ?
Thanks in advance.
“itachi” answer’s right, but if you are looking for in activerecord way…
model: UserHeader
relations:
model: Customer
relations:
and the below code returns the MODEL objects as same as your query. ( I haven’t tested it )