How can I use regular expressions with Doctrine's Mongodb ODM?

后端 未结 2 918
终归单人心
终归单人心 2021-02-08 05:39

I\'m trying to use regular expressions to query Mongodb using Doctrine\'s Mongodb ODM on Symfony 2.

I know the PHP mongo driver can do it. However, I don\'t know how to

2条回答
  •  故里飘歌
    2021-02-08 06:36

    you can follow the Question on stack overflow for detail How to use Reserved characters in createQueryBuilder and MongoRegix,

    Additionally, while /^a/, /^a./, and /^a.$/ match equivalent strings, they have different performance characteristics. All of these expressions use an index if an appropriate index exists; however, /^a./, and /^a.$/ are slower. /^a/ can stop scanning after matching the prefix. Mongo Docs Regix

提交回复
热议问题