5154

Good Luck To You!

php mongodb模糊查询

``php,$collection>find(["field" => new \MongoDB\BSON\Regex("pattern", "i")]);,``

如何在PHP中使用MongoDB进行模糊查询?

在PHP中使用MongoDB进行模糊查询,可以使用正则表达式。,,``php,$collection = $mongodb>selectCollection('your_collection');,$query = ['name' => new MongoDB\BSON\Regex('pattern', 'i')];,$results = $collection>find($query);,`,,这里pattern是你要匹配的字符串模式,i`表示不区分大小写。
<< 1 >>

Powered By Z-BlogPHP 1.7.3

Copyright Your WebSite.Some Rights Reserved.