PHP Doku:: The MongoRegex class - class.mongoregex.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenMongoDB Native DriverTypesThe MongoRegex class

Ein Service von Reinhard Neidl - Webprogrammierung.





The MongoRegex class


This class can be used to create regular expressions. Typically, these expressions will be used to query the database and find matching strings. More unusually, they can be saved to the database and retrieved.

Mongo recognizes six regular expression flags:

  • i

    Case insensitive

  • m


  • x

    Can contain comments

  • l


  • s

    dotall, "." matches everything, including newlines

  • u

    match unicode


MongoRegex {
/* Fields */
public string $regex ;
public string $flags ;
/* Methoden */
__construct ( string $regex )
public string __toString ( void )


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
benyounes dot ousama at gmail dot com
19.11.2010 18:49
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");

// 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();
"Client Name: ".$clientObj["cname"]."</br>";

PHP Powered Diese Seite bei
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)