0

我正在尝试使用 cdbcriteria 在 sql 中获取 min() 的结果。我已经使用了代码

$model = new Serviceproposal;
$criteria = new CDbCriteria(); 
$criteria->select = " MIN(proposal_amount) AS min_proposal_amount,ProposalDescription"; 
$criteria->condition = "Communications= 'hai'"; 
$criteria->join='LEFT JOIN Servicerequest on Servicerequest.ServiceRequestID=Serviceproposal.ServiceRequestID';
$criteria->join="LEFT JOIN user on user.country='India' AND t.user_id = user.user_id";
$results = $model->findAll($criteria);

但我得到了错误Property "Serviceproposal.min_proposal_amount" is not defined.

Database:
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

在模型“Serviceproposal”类中添加属性 public $min_proposal_amount; 喜欢然后使用模型对象访问此属性

class Serviceproposal extends CActiveRecord
{
    public $min_proposal_amount;

}
于 2012-12-14T05:34:34.860 回答