本文介绍了我无法在phalcon集合中使用类似%的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在mongo db中使用了phalcon.模型是 Collection .我想使用find获取

I use phalcon with mongo db. Model is Collection. I want use find to get

SELECT * FROM Users WHERE Username LIKE '%TienNguyen%'

我在mongo db中看到有查询

I see in mongo db have query

b.users.find(
      { Username: /TienNguyen/ }
)

但是在收集Phalcon.我该怎么编码.

But in collection of Phalcon. How do I code it.

我尝试了Users::find([['Username' => "/TienNguyen/"]]);它不起作用.

I tried Users::find([['Username' => "/TienNguyen/"]]);It is not working.

请帮助我

推荐答案

如上所述,未锚定在字符串开头的正则表达式搜索可能会非常昂贵,因为它们需要进行全表扫描.根据您的用例,您可能会考虑使用文本索引.它为不区分大小写的非锚定搜索(包括后缀词干)提供支持.

As was mentioned above, regex searches that are not anchored at the beginning of the string can be very expensive because they require a full table scan. Depending on your use case you might consider using a text index instead. It provides support for case-insensitive non-anchored searches including suffix stemming.

这篇关于我无法在phalcon集合中使用类似%的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 14:05