$query = new Query;
$query->from('product_flat') ->where(['price'=>['$lt'=>$price],'name'=>'连衣裙' ]) ->limit(10); $collection = $query->all(); yii mongodb 如何 如何模糊查询 语句怎样的?
本文由 happysunzone 创作,采用 知识共享署名 3.0 中国大陆许可协议 进行许可。 可自由转载、引用,但需署名作者且注明文章出处。
搜搜一下mongodb 模糊查看会看到语法的
给你写一个模糊查询name中含有dress的数据:
$query->from('product_flat') ->where([ 'name'=>[ '$regex' => 'dress' ] ]); ->limit(10); $collection = $query->all();
嗯 谢谢大神
$query->from('product_flat')
->where([ 'name'=>[ '$regex' => 'dress' ] ]); ->limit(10); $collection = $query->all();
如何根据价格price 降序排列呢? order by price
语法 是?
在yii2中的使用语法,应该和mysql的model是一致的吧
嗯 谢谢大神 好了
@happysunzone #5楼 mongodb的语法,可以查查的,然后套上就可以了
是可以查询,我现在要不区分大小写的查询,应该怎么写?原生的知道是这样写 db.product_flat.find({
"name.name_en":{ $regex:/Alipay/i }
}); ,model中不知道怎么写
@bruceliu3385 #7楼
搜索 name.name_en 为 SomeStringToFind 的 查询语句:
SomeStringToFind
$query->from('product_flat') ->where([ 'name.name_en'=>[ '$regex' => '/^SomeStringToFind$/i' ] ]); ->limit(10); $collection = $query->all();
试试看
这样不行哦,我试过了