php Yii 查找条件 >=

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5335283/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 21:03:40  来源:igfitidea点击:

Yii find condition >=

phpmysqlactiverecordyii

提问by Joeeee

I need to find row where summ>=250

我需要找到 summ>=250 的行

I am doing following:

我正在做以下事情:

$criteria = new CDbCriteria;  
$criteria->condition ='summ >= 250';
$winnerBid = Bids::model()->find($criteria);

But I am getting no results. How to implement?

但我没有得到任何结果。如何实施?

回答by Winfred

I dont have Yii at hand. Have you tried this:

我手头没有 Yii。你有没有试过这个:

$criteria = new CDbCriteria;  
$criteria->addCondition('summ >= 250');
$winnerBid = Bids::model()->find($criteria);

This should work, if summis a column mapped correctly.

如果summ列映射正确,这应该有效。

回答by Mahendran Sakkarai

It will be usefull, try this -

这将是有用的,试试这个 -

$winnerBid = Bids::model()->find(array('condition'=>"summ >= 250"));

回答by jptsetung

$winnerBid = Bids::model()->find('summ >= 250');
if ($winnerBid===null) {
    throw new CHttpException(400,'There is no record in your database with summ>=250.');
}

回答by Alexandre Pereira

$criteria = new CDbCriteria;  
$criteria->condition ='summ >= 250';
$winnerBid = Bids::model()->findAll($criteria);

Since you're using >=you should use FindAll()This should solve your problem.

既然你在使用,>=你应该使用FindAll()这应该可以解决你的问题。