我需要显示最大费率和最低提案率以及使用统计/关系查询由登录用户发布的每个请求的提案数。我使用关系
获得计数或最低费率public function relations()
{
return array('serviceproposals'=>
array(self::HAS_MANY,'Serviceproposal','ServiceRequestID'),
'user' => array(self::BELONGS_TO, 'Buyer', 'user_id'),
'postCount'=>array(self::STAT,'serviceproposal', 'ServiceRequestID','select'=>'MAX(proposal_rate)'),
);
}
使用的数据库包含: -
User[user_id,name,password],
Provider[user_id,providercompany,providerdetails],
Buyer[user_id,contactinfo],
ServiceRequest[ServiceRequestID,Buyer.user_id,details,date],
ServiceProposal[ServiceProposalId,ServiceRequestID,Provider.user_id,services,propsal_rate]
提前致谢..
答案 0 :(得分:1)
由于我的错误,我没有得到计数,最高和最低费率。需要提供2个独立的关系,因此3个值正在变好。
return array(
'serviceproposals' => array(self::HAS_MANY, 'Serviceproposal', 'ServiceRequestID'),
'user' => array(self::BELONGS_TO, 'Buyer', 'user_id'),
'postCount'=>array(self::STAT, 'serviceproposal', 'ServiceRequestID'),
'maxvalue'=>array(self::STAT, 'serviceproposal', 'ServiceRequestID','select'=>'MAX(proposal_amount)'),
'minvalue'=>array(self::STAT, 'serviceproposal', 'ServiceRequestID','select'=>'MIN(proposal_amount)'),
);
}