2015-10-16 151 views
1

我想使用的查询是这样的:Yii2发现查询中使用MongoDB的

Select * from company where id is not null order by id desc 

我使用YII2框架,MongoDB的:

$company = Company::find()->where(['id' => null])->all(); 

上述查询工作正常,我,但我想使用按顺序排列的NOT NULL条件。我怎样才能做到这一点 ?

回答

0

尝试 $company = Company::find()->where(['not', ['id' => null]])->orderBy('id desc')->all();

+0

它给了我一个错误信息:不要求两个操作数 –

+0

嗯......怪你能告诉我其中的文件和行引发此错误?也许你有和我不同的Yii版本。尝试' - >其中(['not','id',null])' –

+0

“name”:“Exception”, “message”:“运算符'NOT'需要两个操作数。”, “code”:0 , “type”:“yii \ base \ InvalidParamException”, “file”:“/local/project/vendor/yiisoft/yii2-mongodb/Collection.php”, “line”:906, –