La classe MongoDB\BSON\Regex

(mongodb >=1.0.0)

Introduction

Type BSON pour un modèle d'expression régulière et » flags facultatif.

Note: Ce type BSON est principalement utilisé lors de l'interrogation de la base de données. Alternativement, l'opérateur de requête » $regex peut être utilisé.

Synopsis de la classe

final MongoDB\BSON\Regex implements MongoDB\BSON\RegexInterface , MongoDB\BSON\Type , Serializable , JsonSerializable {
/* Méthodes */
final public __construct(string $pattern, string $flags = "")
final public getFlags(): string
final public getPattern(): string
final public jsonSerialize(): mixed
final public serialize(): string
final public __toString(): string
final public unserialize(string $serialized): void
}

Historique

Version Description
PECL mongodb1.3.0 Implémente MongoDB\BSON\RegexInterface.
PECL mongodb1.2.0 Implémente Serializable et JsonSerializable.

Sommaire

add a note add a note

User Contributed Notes 2 notes

up
-26
aws dot htc at gmail dot com
7 years ago
Example
Find names that start with "Al"

$regex = new MongoDB\BSON\Regex ( '^Al');
$cursor = $collection->find(array('name' => $regex));
//iterate through the cursor
To Top