【问题标题】:How to find minimum and maximum rate in Yii using Statistical or Relational query如何使用统计或关系查询在 Yii 中找到最小和最大速率
【发布时间】:2012-12-06 04:35:30
【问题描述】:

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

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]

提前谢谢..

【问题讨论】:

    标签: php mysql yii phpmyadmin


    【解决方案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)'),
    
      );
     }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多