我正在尝试使用 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]
如何获得最小提案金额的结果?