"itachi" answers correctly, but if you are looking in an activerecord way ...
Model: UserHeader
relations:
'activeCustomers' => array( self::HAS_MANY, 'Customer', 'customer_user_id', 'condition' => 'activeCustomers.rate_auto_approve=0 AND activeCustomers.rate_email_time IS NOT NULL AND activeCustomers.total_rating_count IS NOT NULL' ),
Model: Customer
relations:
'lastWeekRatings' => array( self::HAS_MANY, 'CustomerRating', 'customer_user_id', 'condition' => 'lastWeekRatings.rating_date < CURDATE() AND lastWeekRatings.rating_date > DATE_SUB( CURDATE(), INTERVAL 7 DAY )' ),
and the code below returns MODEL objects just like your request. (I have not tested it)
$useremails = UserHeader::model() ->with('activeCustomers', 'activeCustomers.lastWeekRatings') ->findAll(array( 'select' => 't.email' )); print_r($useremails);
source share