2

对于登录用户使用统计/关系查询发布的每个请求,我需要显示最大速率和最小提案速率以及提案计数。我正在使用关系获得计数或最低比率

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]

提前致谢..

4

1 回答 1

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)'),

  );
 }
于 2012-12-06T06:17:35.167 回答