(PECL mongo >=0.8.1)
这个类用于创建一个正则表达式。 通常这些表达式用于查询数据库中匹配的字符串。不常用的是,它们可以保存到数据库并用于检索。
Mongo 能够识别六种正则表达式标记(flag):
i
忽略大小写
m
多行
x
能够包含注释
l
语言环境
s
dotall,"." 匹配任何字符,包括换行符。
u
匹配 Unicode
benyounes dot ousama at gmail dot com (2010-11-19 09:49:26)
First you must declare and define your regexObj
Here I am looking for all entry of my database wich is like "%Nicolas%" and the /i param is used for Insensitive Case
$regexObj = new MongoRegex("/^Nicolas/i");
<?php
// I attach the regexObj to my Where Condition
$where = array("ctname" => $regexObj);
// Execute the request
$resultset = $this->db->Infos->find($where);
// Parsing the results
while ($resultset->hasNext())
{
$clientObj = $resultset->getNext();
echo "Client Name: ".$clientObj["cname"]."</br>";
}
?>